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 "entity/message" #1097

Merged
merged 50 commits into from
Apr 20, 2017
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f94fd0e
Asset.js
bennycode Apr 12, 2017
41edb2b
Removed "shield"
bennycode Apr 12, 2017
6de59c7
Merge branch 'dev' into es6-entity
bennycode Apr 13, 2017
c2a5b43
Revert
bennycode Apr 13, 2017
5278474
Asset.js
bennycode Apr 13, 2017
cf0691a
Asset ES6 class
bennycode Apr 13, 2017
e390abd
z.entity.Asset
bennycode Apr 13, 2017
13f72ab
Location.js
bennycode Apr 13, 2017
7eaaad1
z.entity.MediumImage
bennycode Apr 13, 2017
4b64141
z.entity.File
bennycode Apr 13, 2017
5c3ca5f
z.entity.Message
bennycode Apr 13, 2017
0ad8fda
z.entity.VerificationMessage
bennycode Apr 13, 2017
c6bd7cf
z.entity.SystemMessage
bennycode Apr 13, 2017
c7ce65d
z.entity.CallMessage
bennycode Apr 13, 2017
b5d0ad7
z.entity.PingMessage
bennycode Apr 13, 2017
a3890cf
z.entity.DecryptErrorMessage [ci-skip]
bennycode Apr 13, 2017
9f90c85
z.entity.ContentMessage
bennycode Apr 13, 2017
607195b
z.entity.DeleteMessage
bennycode Apr 13, 2017
d4ff6ab
[ci-skip] z.entity.RenameMessage
bennycode Apr 13, 2017
cac9c7a
[ci-skip] z.entity.MemberMessage
bennycode Apr 13, 2017
71a8776
fixed tests
bennycode Apr 13, 2017
006af4e
z.entity.LinkPreview
bennycode Apr 13, 2017
e9d752d
Merge branch 'dev' into es6-entity
bennycode Apr 18, 2017
9844645
JSDoc
bennycode Apr 18, 2017
58f76a2
Linting
bennycode Apr 18, 2017
477d8ae
JSDoc
bennycode Apr 18, 2017
6e1ba64
JSDoc
bennycode Apr 18, 2017
7aea724
JSDoc linting
bennycode Apr 18, 2017
06db0bc
Style
bennycode Apr 18, 2017
3d9050e
Merge branch 'dev' into es6-entity
bennycode Apr 18, 2017
a0c7634
changed order
bennycode Apr 18, 2017
3270119
Merge branch 'dev' into es6-entity
bennycode Apr 19, 2017
9d4f2c7
PRR
bennycode Apr 19, 2017
6f3aa15
Promise.resolve(undefined)
bennycode Apr 19, 2017
16be6c6
PRR
bennycode Apr 19, 2017
73f67ad
PRR
bennycode Apr 19, 2017
6f0c047
PRR [ci-skip]
bennycode Apr 19, 2017
214187a
PRR [ci-skip]
bennycode Apr 19, 2017
28d8a40
PRR [ci-skip]
bennycode Apr 19, 2017
7cd1f16
PRR [ci-skip]
bennycode Apr 19, 2017
b4b2953
PRR [ci-skip]
bennycode Apr 19, 2017
982c01c
PRR [ci-skip]
bennycode Apr 19, 2017
1e9b30a
PRR
bennycode Apr 19, 2017
6ed9218
Merge branch 'dev' into es6-entity
bennycode Apr 19, 2017
3b7125b
Fixed linting
bennycode Apr 19, 2017
54ccdf2
Removed safety nets
bennycode Apr 19, 2017
a783bf1
Review fixes
bennycode Apr 19, 2017
5216a9e
Updated coverage threshold
bennycode Apr 20, 2017
fbcbc55
Merge branch 'dev' into es6-entity
bennycode Apr 20, 2017
3f1d437
PRR
bennycode Apr 20, 2017
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
87 changes: 0 additions & 87 deletions app/script/entity/message/Asset.coffee

This file was deleted.

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

z.entity.Asset = class Asset {
constructor(id) {
this.id = id;
this.key = '';
this.type = '';
}

/**
* Check if asset is a medium image.
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all these empty lines in docs?

* @returns {Boolean} Is asset of type medium image
*/
is_image() {
return this.type === z.assets.AssetType.IMAGE;
}

/**
* Check if asset is a text.
*
* @returns {Boolean} Is asset of type text
*/
is_text() {
return this.type === z.assets.AssetType.TEXT;
}

/**
* Check if asset is a file.
*
* @returns {Boolean} Is asset of type file
*/
is_file() {
return this.type === z.assets.AssetType.FILE && !this.is_video() && !this.is_audio();
}

/**
* Check if asset is a location.
*
* @returns {Boolean} Is asset of type location
*/
is_location() {
return this.type === z.assets.AssetType.LOCATION;
}

/**
* Check if asset is a video.
*
* @returns {Boolean} Is asset of type video
*/
is_video() {
const is_video_asset = (this.type === z.assets.AssetType.FILE) && (this.file_type != null ? this.file_type.startsWith('video') : undefined);
Copy link
Contributor

@gregor gregor Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const is_video_asset = this.type === z.assets.AssetType.FILE && this.file_type && this.file_type.startsWith('video');

seems easier to read to me

if (is_video_asset) {
const can_play = document.createElement('video').canPlayType(this.file_type);
if (can_play !== '') {
return true;
}
}
return false;
}

/**
* Check if asset is a audio.
*
* @returns {Boolean} Is asset of type audio
*/
is_audio() {
if ((this.type === z.assets.AssetType.FILE) && (this.file_type != null ? this.file_type.startsWith('audio') : undefined)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

const can_play = document.createElement('audio').canPlayType(this.file_type);
if (can_play !== '') {
return true;
}
}
return false;
}
};
54 changes: 0 additions & 54 deletions app/script/entity/message/CallMessage.coffee

This file was deleted.

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

z.entity.CallMessage = class CallMessage extends z.entity.Message {
constructor() {
super();
this.super_type = z.message.SuperType.CALL;
this.call_message_type = '';
this.finished_reason = '';

this.caption = ko.pureComputed(() => {
if (this.user().is_me) {
return z.localization.Localizer.get_text(z.string.conversation_voice_channel_deactivate_you);
}
return z.localization.Localizer.get_text(z.string.conversation_voice_channel_deactivate);
}, this, {deferEvaluation: true});
}

/**
* Check if call message is call activation.
* @returns {Boolean} Is message of type activate
*/
is_activation() {
return this.call_message_type === z.message.CALL_MESSAGE_TYPE.ACTIVATED;
}

/**
* Check if call message is call deactivation.
* @returns {Boolean} Is message of type deactivate
*/
is_deactivation() {
return this.call_message_type === z.message.CALL_MESSAGE_TYPE.DEACTIVATED;
}

was_completed() {
return this.finished_reason === z.calling.enum.TERMINATION_REASON.COMPLETED;
}

was_missed() {
return this.finished_reason === z.calling.enum.TERMINATION_REASON.MISSED;
}
};
Loading