Skip to content

Commit

Permalink
ES6 migrate 'conversation'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Herdmann committed May 3, 2017
1 parent ad666a6 commit edfd82f
Show file tree
Hide file tree
Showing 29 changed files with 5,110 additions and 1,661 deletions.
2 changes: 1 addition & 1 deletion app/script/calling/handler/CallStateHandler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class z.calling.handler.CallStateHandler
@on_call_state @_fake_on_state_event(response, conversation_id), true
@v2_call_center.conversation_repository.unarchive_conversation conversation_et if conversation_et.is_archived()
.catch (error) ->
throw error unless error.type is z.conversation.ConversationError::TYPE.NOT_FOUND
throw error unless error.type is z.conversation.ConversationError.TYPE.NOT_FOUND

###
Set the notification handling state.
Expand Down
59 changes: 0 additions & 59 deletions app/script/conversation/ConversationError.coffee

This file was deleted.

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

z.conversation.ConversationError = class ConversationError extends Error {
constructor(type) {
super();

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

switch (this.type) {
case z.conversation.ConversationError.TYPE.CONVERSATION_NOT_FOUND:
this.message = 'Conversation not found';
break;
case z.conversation.ConversationError.TYPE.DEGRADED_CONVERSATION_CANCELLATION:
this.message = 'Sending to degraded conversation was canceled by user';
break;
case z.conversation.ConversationError.TYPE.MESSAGE_NOT_FOUND:
this.message = 'Message not found';
break;
case z.conversation.ConversationError.TYPE.NO_CHANGES:
this.message = 'Missing changes to message';
break;
case z.conversation.ConversationError.TYPE.NO_CONVERSATION_ID:
this.message = 'Conversation ID is not defined';
break;
case z.conversation.ConversationError.TYPE.NOT_FOUND:
this.message = 'Conversation not found';
break;
case z.conversation.ConversationError.TYPE.REQUEST_FAILED:
this.message = 'Conversation related backend request failed';
break;
case z.conversation.ConversationError.TYPE.WRONG_USER:
this.message = 'Wrong user tried to change or delete a message';
break;
default:
this.message = 'Unknown ConversationError';
}
}

static get TYPE() {
return {
CONVERSATION_NOT_FOUND: 'z.conversation.ConversationError.TYPE.CONVERSATION_NOT_FOUND',
DEGRADED_CONVERSATION_CANCELLATION: 'z.conversation.ConversationError.TYPE.DEGRADED_CONVERSATION_CANCELLATION',
MESSAGE_NOT_FOUND: 'z.conversation.ConversationError.TYPE.MESSAGE_NOT_FOUND',
NO_CHANGES: 'z.conversation.ConversationError.TYPE.NO_CHANGES',
NO_CONVERSATION_ID: 'z.conversation.ConversationError.TYPE.NO_CONVERSATION_ID',
NOT_FOUND: 'z.conversation.ConversationError.TYPE.NOT_FOUND',
REQUEST_FAILURE: 'z.conversation.ConversationError.TYPE.REQUEST_FAILURE',
UNKNOWN: 'z.conversation.ConversationError.TYPE.UNKNOWN',
WRONG_USER: 'z.conversation.ConversationError.TYPE.WRONG_USER',
};
}
};
189 changes: 0 additions & 189 deletions app/script/conversation/ConversationMapper.coffee

This file was deleted.

Loading

0 comments on commit edfd82f

Please sign in to comment.