Skip to content

Commit

Permalink
Improved support for calls service messages
Browse files Browse the repository at this point in the history
  • Loading branch information
zhukov committed May 10, 2017
1 parent e6395fa commit facd3bf
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 20 deletions.
8 changes: 4 additions & 4 deletions app/js/locales/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,10 @@
"message_service_joined_by_link": "joined group via invite link",
"message_service_joined": "joined the group",
"message_service_pinned_message": "pinned «{message}»",
"message_service_phonecall_incoming": "Incoming Call {duration}",
"message_service_phonecall_outgoing": "Outgoing Call {duration}",
"message_service_phonecall_missed": "Missed Call {duration}",
"message_service_phonecall_canceled": "Canceled Call {duration}",
"message_service_phonecall_incoming": "Incoming Call",
"message_service_phonecall_outgoing": "Outgoing Call",
"message_service_phonecall_missed": "Missed Call",
"message_service_phonecall_canceled": "Canceled Call",
"message_service_phonecall": "Phone call {duration}",
"message_service_scored_game": "{scored} in {message}",
"message_service_unsupported_action": "unsupported action {action}",
Expand Down
25 changes: 25 additions & 0 deletions app/js/messages_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,14 @@ angular.module('myApp.services')

case 'messageActionPhoneCall':
delete apiMessage.fromID
apiMessage.action.type =
(apiMessage.pFlags.out ? 'out_' : 'in_') +
(
apiMessage.action.reason._ == 'phoneCallDiscardReasonMissed' ||
apiMessage.action.reason._ == 'phoneCallDiscardReasonBusy'
? 'missed'
: 'ok'
)
break
}
if (migrateFrom &&
Expand Down Expand Up @@ -2777,6 +2785,23 @@ angular.module('myApp.services')
case 'messageActionGameScore':
notificationMessage = gameScorePluralize(message.action.score)
break

case 'messageActionPhoneCall':
switch (message.action.type) {
case 'out_missed':
notificationMessage = _('message_service_phonecall_canceled_raw')
break
case 'in_missed':
notificationMessage = _('message_service_phonecall_missed_raw')
break
case 'out_ok':
notificationMessage = _('message_service_phonecall_outgoing_raw')
break
case 'in_ok':
notificationMessage = _('message_service_phonecall_incoming_raw')
break
}
break
}
}

Expand Down
14 changes: 6 additions & 8 deletions app/partials/desktop/message_service.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@
<my-i18n-param name="message"><a class="im_service_message_pinned" my-pinned-message="::historyMessage.reply_to_mid"></a></my-i18n-param>
</span>

<a ng-switch-when="messageActionPhoneCall" class="im_service_message_phonecall" ng-click="phoneCallClick(historyMessage.mid)">
<my-i18n ng-switch="(historyMessage.pFlags.out ? 'out' : 'in') + (historyMessage.action.reason._ == 'phoneCallDiscardReasonMissed' || historyMessage.action.reason._ == 'phoneCallDiscardReasonBusy' ? 'missed' : 'ok')">
<span ng-switch-when="outmissed" my-i18n-format="message_service_phonecall_canceled"></span>
<span ng-switch-when="inmissed" my-i18n-format="message_service_phonecall_missed"></span>
<span ng-switch-when="outok" my-i18n-format="message_service_phonecall_outgoing"></span>
<span ng-switch-when="inok" my-i18n-format="message_service_phonecall_incoming"></span>
<my-i18n-param name="duration"><span ng-if="historyMessage.action.duration > 0" ng-bind="historyMessage.action.duration | duration" class="im_service_message_phonecall_duration"></span></my-i18n-param>
</my-i18n>
<a ng-switch-when="messageActionPhoneCall" class="im_service_message_phonecall" ng-click="phoneCallClick(historyMessage.mid)" ng-switch="historyMessage.action.type">
<span ng-switch-when="out_missed" my-i18n="message_service_phonecall_canceled"></span>
<span ng-switch-when="in_missed" my-i18n="message_service_phonecall_missed"></span>
<span ng-switch-when="out_ok" my-i18n="message_service_phonecall_outgoing"></span>
<span ng-switch-when="in_ok" my-i18n="message_service_phonecall_incoming"></span>
<span ng-if="historyMessage.action.duration > 0" ng-bind="historyMessage.action.duration | duration" class="im_service_message_phonecall_duration"></span>
</a>


Expand Down
6 changes: 6 additions & 0 deletions app/partials/desktop/short_message.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,11 @@
when="conversation_scored_X"></ng-pluralize>
</my-i18n-param>
</span>
<span ng-switch-when="messageActionPhoneCall" ng-switch="message.action.type">
<span ng-switch-when="out_missed" my-i18n="message_service_phonecall_canceled"></span>
<span ng-switch-when="in_missed" my-i18n="message_service_phonecall_missed"></span>
<span ng-switch-when="out_ok" my-i18n="message_service_phonecall_outgoing"></span>
<span ng-switch-when="in_ok" my-i18n="message_service_phonecall_incoming"></span>
</span>

</span><span class="im_short_message_text" ng-if="message.message.length && (!message.media || message.media._ == 'messageMediaWebPage')" ng-bind-html="message.richMessage"></span>
14 changes: 6 additions & 8 deletions app/partials/mobile/message_service.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@
<my-i18n-param name="message"><a my-pinned-message="historyMessage.reply_to_mid"></a></my-i18n-param>
</span>

<a ng-switch-when="messageActionPhoneCall" class="im_service_message_phonecall" ng-click="phoneCallClick(historyMessage.mid)">
<my-i18n ng-switch="(historyMessage.pFlags.out ? 'out' : 'in') + (historyMessage.action.reason._ == 'phoneCallDiscardReasonMissed' || historyMessage.action.reason._ == 'phoneCallDiscardReasonBusy' ? 'missed' : 'ok')">
<span ng-switch-when="outmissed" my-i18n-format="message_service_phonecall_canceled"></span>
<span ng-switch-when="inmissed" my-i18n-format="message_service_phonecall_missed"></span>
<span ng-switch-when="outok" my-i18n-format="message_service_phonecall_outgoing"></span>
<span ng-switch-when="inok" my-i18n-format="message_service_phonecall_incoming"></span>
<my-i18n-param name="duration"><span ng-if="historyMessage.action.duration > 0" ng-bind="historyMessage.action.duration | duration" class="im_service_message_phonecall_duration"></span></my-i18n-param>
</my-i18n>
<a ng-switch-when="messageActionPhoneCall" class="im_service_message_phonecall" ng-click="phoneCallClick(historyMessage.mid)" ng-switch="historyMessage.action.type">
<span ng-switch-when="out_missed" my-i18n="message_service_phonecall_canceled"></span>
<span ng-switch-when="in_missed" my-i18n="message_service_phonecall_missed"></span>
<span ng-switch-when="out_ok" my-i18n="message_service_phonecall_outgoing"></span>
<span ng-switch-when="in_ok" my-i18n="message_service_phonecall_incoming"></span>
<span ng-if="historyMessage.action.duration > 0" ng-bind="historyMessage.action.duration | duration" class="im_service_message_phonecall_duration"></span>
</a>

<span ng-switch-default my-i18n="message_service_unsupported_action">
Expand Down

0 comments on commit facd3bf

Please sign in to comment.