Skip to content

Commit

Permalink
ES6: migrated "event"
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Herdmann committed Apr 18, 2017
1 parent 9f80828 commit d6d5fe5
Show file tree
Hide file tree
Showing 31 changed files with 1,497 additions and 1,194 deletions.
2 changes: 1 addition & 1 deletion app/script/audio/AudioRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ window.z.audio.AudioRepository = class AudioRepository {
*/
_subscribe_to_events() {
amplify.subscribe(z.event.WebApp.EVENT.NOTIFICATION_HANDLING_STATE, this, (handling_notifications) => {
this.muted = handling_notifications !== z.event.NotificationHandlingState.WEB_SOCKET;
this.muted = handling_notifications !== z.event.NOTIFICATION_HANDLING_STATE.WEB_SOCKET;
this.logger.info(`Set muted state to '${this.muted}'`);
});

Expand Down
4 changes: 2 additions & 2 deletions app/script/calling/handler/CallStateHandler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ class z.calling.handler.CallStateHandler
###
Set the notification handling state.
@note Temporarily ignore call related events when handling notifications from the stream
@param handling_state [z.event.NotificationHandlingState] State of the notifications stream handling
@param handling_state [z.event.NOTIFICATION_HANDLING_STATE] State of the notifications stream handling
###
set_notification_handling_state: (handling_state) =>
@block_event_handling = handling_state isnt z.event.NotificationHandlingState.WEB_SOCKET
@block_event_handling = handling_state isnt z.event.NOTIFICATION_HANDLING_STATE.WEB_SOCKET
@_update_ongoing_calls() if not @block_event_handling
@logger.info "Block handling of call events: #{@block_event_handling}"

Expand Down
4 changes: 2 additions & 2 deletions app/script/calling/v3/CallCenter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class z.calling.v3.CallCenter
###
Set the notification handling state.
@note Temporarily ignore call related events when handling notifications from the stream
@param handling_state [z.event.NotificationHandlingState] State of the notifications stream handling
@param handling_state [z.event.NOTIFICATION_HANDLING_STATE] State of the notifications stream handling
###
set_notification_handling_state: (handling_state) =>
@block_media_stream = handling_state isnt z.event.NotificationHandlingState.WEB_SOCKET
@block_media_stream = handling_state isnt z.event.NOTIFICATION_HANDLING_STATE.WEB_SOCKET
@logger.info "Block requesting MediaStream: #{@block_media_stream}"


Expand Down
4 changes: 2 additions & 2 deletions app/script/conversation/ConversationRepository.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,10 @@ class z.conversation.ConversationRepository
###
Set the notification handling state.
@note Temporarily do not unarchive conversations when handling the notification stream
@param handling_state [z.event.NotificationHandlingState] State of the notifications stream handling
@param handling_state [z.event.NOTIFICATION_HANDLING_STATE] State of the notifications stream handling
###
set_notification_handling_state: (handling_state) =>
@block_event_handling = handling_state isnt z.event.NotificationHandlingState.WEB_SOCKET
@block_event_handling = handling_state isnt z.event.NOTIFICATION_HANDLING_STATE.WEB_SOCKET
@sending_queue.pause @block_event_handling
@logger.info "Block handling of conversation events: #{@block_event_handling}"

Expand Down
2 changes: 1 addition & 1 deletion app/script/ephemeral/ephemeralTimings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Wire
* Copyright (C) 2016 Wire Swiss GmbH
* 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
Expand Down
55 changes: 0 additions & 55 deletions app/script/event/Backend.coffee

This file was deleted.

59 changes: 59 additions & 0 deletions app/script/event/Backend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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.event = z.event || {};

z.event.Backend = {
CALL: {
FLOW_ACTIVE: 'call.flow-active',
FLOW_ADD: 'call.flow-add',
FLOW_DELETE: 'call.flow-delete',
REMOTE_CANDIDATES_ADD: 'call.remote-candidates-add',
REMOTE_CANDIDATES_UPDATE: 'call.remote-candidates-update',
REMOTE_SDP: 'call.remote-sdp',
STATE: 'call.state',
},
CONVERSATION: {
ASSET_ADD: 'conversation.asset-add',
CONNECT_REQUEST: 'conversation.connect-request',
CREATE: 'conversation.create',
KNOCK: 'conversation.knock',
MEMBER_JOIN: 'conversation.member-join',
MEMBER_LEAVE: 'conversation.member-leave',
MEMBER_UPDATE: 'conversation.member-update',
MESSAGE_ADD: 'conversation.message-add',
OTR_ASSET_ADD: 'conversation.otr-asset-add',
OTR_MESSAGE_ADD: 'conversation.otr-message-add',
RENAME: 'conversation.rename',
TYPING: 'conversation.typing',
VOICE_CHANNEL_ACTIVATE: 'conversation.voice-channel-activate',
VOICE_CHANNEL_DEACTIVATE: 'conversation.voice-channel-deactivate',
},
USER: {
ACTIVATE: 'user.activate',
CLIENT_ADD: 'user.client-add',
CLIENT_REMOVE: 'user.client-remove',
CONNECTION: 'user.connection',
DELETE: 'user.delete',
UPDATE: 'user.update',
},
};
38 changes: 0 additions & 38 deletions app/script/event/Client.coffee

This file was deleted.

44 changes: 44 additions & 0 deletions app/script/event/Client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.event = z.event || {};

z.event.Client = {
CALL: {
E_CALL: 'call.e-call',
},
CONVERSATION: {
ASSET_META: 'conversation.asset-meta',
ASSET_PREVIEW: 'conversation.asset-preview',
ASSET_UPLOAD_COMPLETE: 'conversation.asset-upload-complete',
ASSET_UPLOAD_FAILED: 'conversation.asset-upload-failed',
CONFIRMATION: 'conversation.confirmation',
DELETE_EVERYWHERE: 'conversation.delete-everywhere',
LOCATION: 'conversation.location',
MESSAGE_DELETE: 'conversation.message-delete',
MESSAGE_HIDDEN: 'conversation.message-hidden',
MISSED_MESSAGES: 'conversation.missed-messages',
REACTION: 'conversation.reaction',
UNABLE_TO_DECRYPT: 'conversation.unable-to-decrypt',
VERIFICATION: 'conversation.verification',
},
};
55 changes: 0 additions & 55 deletions app/script/event/EventError.coffee

This file was deleted.

72 changes: 72 additions & 0 deletions app/script/event/EventError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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.event = z.event || {};

z.event.EventError = class EventError extends Error {
constructor(type) {
super();

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

switch (this.type) {
case z.event.EventError.TYPE.DATABASE_FAILURE:
this.message = 'Event related database transaction failure';
break;
case z.event.EventError.TYPE.DEPRECATED_SCHEMA:
this.message = 'Event type is deprecated';
break;
case z.event.EventError.TYPE.NO_CLIENT_ID:
this.message = 'Missing client id';
break;
case z.event.EventError.TYPE.NO_LAST_ID:
this.message = 'Last notification ID not found in storage';
break;
case z.event.EventError.TYPE.NO_NOTIFICATIONS:
this.message = 'No notifications found';
break;
case z.event.EventError.TYPE.OUTDATED_E_CALL_EVENT:
this.message = 'Ignoring outdated e-call event';
break;
case z.event.EventError.TYPE.REQUEST_FAILURE:
this.message = 'Event related backend request failure';
break;
default:
this.message = 'Unknown EventError';

}
}

static get TYPE() {
return {
DATABASE_FAILURE: 'z.event.EventError.TYPE.DATABASE_FAILURE',
DEPRECATED_SCHEMA: 'z.event.EventError.TYPE.DEPRECATED_SCHEMA',
NO_CLIENT_ID: 'z.event.EventError.TYPE.NO_CLIENT_ID',
NO_LAST_ID: 'z.event.EventError.TYPE.NO_LAST_ID',
NO_NOTIFICATIONS: 'z.event.EventError.TYPE.NO_NOTIFICATIONS',
OUTDATED_E_CALL_EVENT: 'z.event.EventError.OUTDATED_E_CALL_EVENT',
REQUEST_FAILURE: 'z.event.EventError.TYPE.REQUEST_FAILURE',
};
}
};
Loading

0 comments on commit d6d5fe5

Please sign in to comment.