Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6: migrated "system_notification" #1052

Merged
merged 1 commit into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/script/conversation/EventMapper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,8 @@ class z.conversation.EventMapper
@return [z.entity.Text] Text asset entity
###
_map_asset_text: (data) ->
asset_et = new z.entity.Text data.id
asset_et = new z.entity.Text data.id, data.content or data.message
asset_et.nonce = data.nonce
asset_et.text = data.content or data.message
asset_et.previews @_map_link_previews data.previews
return asset_et

Expand Down
4 changes: 2 additions & 2 deletions app/script/entity/message/Text.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class z.entity.Text extends z.entity.Asset

@param id [String] Asset ID
###
constructor: (id) ->
constructor: (id, text = '') ->
super id
@type = z.assets.AssetType.TEXT
@nonce = undefined

# Raw message text
@text = ''
@text = text

# Can be used to theme media embeds
@theme_color = undefined
Expand Down
2 changes: 1 addition & 1 deletion app/script/main/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class z.main.App
repository.bot = new z.bot.BotRepository @service.bot, repository.conversation
repository.calling = new z.calling.CallingRepository @service.call, @service.calling, repository.conversation, repository.media, repository.user
repository.event_tracker = new z.tracking.EventTrackingRepository repository.user, repository.conversation
repository.system_notification = new z.SystemNotification.SystemNotificationRepository repository.calling, repository.conversation
repository.system_notification = new z.system_notification.SystemNotificationRepository repository.calling, repository.conversation

return repository

Expand Down
30 changes: 0 additions & 30 deletions app/script/system_notification/PermissionStatusState.coffee

This file was deleted.

33 changes: 33 additions & 0 deletions app/script/system_notification/PermissionStatusState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.system_notification = z.system_notification || {};

// https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus/state
z.system_notification.PermissionStatusState = {
DEFAULT: 'default',
DENIED: 'denied',
GRANTED: 'granted',
IGNORED: 'ignored',
PROMPT: 'prompt',
UNSUPPORTED: 'unsupported',
};
38 changes: 0 additions & 38 deletions app/script/system_notification/SystemNotificationError.coffee

This file was deleted.

48 changes: 48 additions & 0 deletions app/script/system_notification/SystemNotificationError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.system_notification = z.system_notification || {};

z.system_notification.SystemNotificationError = class SystemNotificationError extends Error {
constructor(type) {
super();

this.name = this.constructor.name;
this.stack = (new Error()).stack;
this.type = type || z.cryptography.CryptographyError.TYPE.UNKNOWN;

switch (this.type) {
case z.system_notification.SystemNotificationError.TYPE.HIDE_NOTIFICATION:
this.message = 'Do not show notification for this message';
break;
default:
this.message = 'Unknown SystemNotificationError';
}
}

static get TYPE() {
return {
HIDE_NOTIFICATION: 'z.system_notification.SystemNotificationError.TYPE.HIDE_NOTIFICATION',
UNKNOWN: 'z.system_notification.SystemNotificationError.TYPE.UNKNOWN',
};
}
};

This file was deleted.

31 changes: 31 additions & 0 deletions app/script/system_notification/SystemNotificationPreference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.system_notification = z.system_notification || {};

// Enum of notification preferences.
z.system_notification.SystemNotificationPreference = {
NONE: 'none',
OBFUSCATE: 'obfuscate',
OBFUSCATE_MESSAGE: 'obfuscate-message',
ON: 'on',
};
Loading