-
Notifications
You must be signed in to change notification settings - Fork 292
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
Changes from 29 commits
f94fd0e
41edb2b
6de59c7
c2a5b43
5278474
cf0691a
e390abd
13f72ab
7eaaad1
4b64141
5c3ca5f
0ad8fda
c6bd7cf
c7ce65d
b5d0ad7
a3890cf
9f90c85
607195b
d4ff6ab
cac9c7a
71a8776
006af4e
e9d752d
9844645
58f76a2
477d8ae
6e1ba64
7aea724
06db0bc
3d9050e
a0c7634
3270119
9d4f2c7
6f3aa15
16be6c6
73f67ad
6f0c047
214187a
28d8a40
7cd1f16
b4b2953
982c01c
1e9b30a
6ed9218
3b7125b
54ccdf2
a783bf1
5216a9e
fbcbc55
3f1d437
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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. | ||
* | ||
* @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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
} | ||
}; |
This file was deleted.
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; | ||
} | ||
}; |
There was a problem hiding this comment.
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?