Browse Source

Supported pinned service messages

master
Igor Zhukov 9 years ago
parent
commit
e126d2830b
  1. 57
      app/js/directives.js
  2. 3
      app/js/lib/utils.js
  3. 2
      app/js/locales/en-us.json
  4. 30
      app/less/app.less
  5. 22
      app/partials/desktop/dialog.html
  6. 22
      app/partials/desktop/forwarded_messages.html
  7. 5
      app/partials/desktop/message_service.html
  8. 1
      app/partials/desktop/pinned_message.html
  9. 23
      app/partials/desktop/reply_message.html
  10. 22
      app/partials/desktop/short_message.html
  11. 22
      app/partials/mobile/dialog.html
  12. 4
      app/partials/mobile/message_service.html

57
app/js/directives.js

@ -330,16 +330,16 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -330,16 +330,16 @@ angular.module('myApp.directives', ['myApp.filters'])
};
})
.directive('myServiceShortMessage', function() {
.directive('myShortMessage', function() {
return {
scope: {
message: '=myServiceShortMessage'
message: '=myShortMessage'
},
templateUrl: templateUrl('dialog_service')
templateUrl: templateUrl('short_message')
};
})
.directive('myReplyMessage', function(AppPhotosManager, AppMessagesManager, AppPeersManager, $rootScope) {
.directive('myReplyMessage', function(AppMessagesManager, AppPeersManager, $rootScope) {
return {
templateUrl: templateUrl('reply_message'),
@ -400,6 +400,55 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -400,6 +400,55 @@ angular.module('myApp.directives', ['myApp.filters'])
})
.directive('myPinnedMessage', function(AppMessagesManager, AppPeersManager, $rootScope) {
return {
templateUrl: templateUrl('pinned_message'),
scope: {
'pinnedMessage': '=myPinnedMessage'
},
link: link
};
function link ($scope, element, attrs) {
var message = $scope.pinnedMessage;
if (!message.loading) {
updateMessage($scope, element);
} else {
var mid = message.mid;
var stopWaiting = $scope.$on('messages_downloaded', function (e, mids) {
if (mids.indexOf(mid) != -1) {
$scope.pinnedMessage = AppMessagesManager.wrapForDialog(mid);
updateMessage($scope, element);
stopWaiting();
}
});
}
}
function updateMessage($scope, element) {
var message = $scope.pinnedMessage;
if (!message || message.deleted || !message.to_id) {
$(element).remove();
return;
}
if (element[0].tagName == 'A') {
element.on('click', function () {
var peerID = AppMessagesManager.getMessagePeer(message);
var peerString = AppPeersManager.getPeerString(peerID);
$rootScope.$broadcast('history_focus', {peerString: peerString, messageID: message.mid});
})
}
onContentLoaded(function () {
$scope.$emit('ui_height');
})
}
})
.directive('myForwardedMessages', function(AppPhotosManager, AppMessagesManager, AppPeersManager, $rootScope) {
return {

3
app/js/lib/utils.js

@ -379,7 +379,8 @@ function templateUrl (tplName) { @@ -379,7 +379,8 @@ function templateUrl (tplName) {
forwarded_messages: 'desktop',
chat_invite_link_modal: 'desktop',
reply_markup: 'desktop',
dialog_service: 'desktop',
short_message: 'desktop',
pinned_message: 'desktop',
channel_edit_modal: 'desktop',
megagroup_edit_modal: 'desktop',
inline_results: 'desktop',

2
app/js/locales/en-us.json

@ -308,6 +308,7 @@ @@ -308,6 +308,7 @@
"conversation_changed_channel_name": "Channel renamed",
"conversation_changed_channel_photo": "Channel photo updated",
"conversation_removed_channel_photo": "Channel photo removed",
"conversation_pinned_message": "pinned message",
"conversation_message_sent": "sent you a message",
"conversation_forwarded_X_messages": "{'one': 'forwarded {} message', 'other': 'forwarded {} messages'}",
@ -326,6 +327,7 @@ @@ -326,6 +327,7 @@
"message_service_left_group": "left group",
"message_service_joined_by_link": "joined group via invite link",
"message_service_joined": "joined the group",
"message_service_pinned_message": "pinned message «{message}»",
"message_service_unsupported_action": "unsupported action {action}",
"message_service_bot_intro_header": "What can this bot do?",
"message_service_converted_to_supergroup": "upgraded the group to a supergroup",

30
app/less/app.less

@ -1293,17 +1293,17 @@ i.icon-verified { @@ -1293,17 +1293,17 @@ i.icon-verified {
word-wrap: break-word;
}
.im_dialog_chat_from_wrap,
.im_dialog_message_media,
.im_dialog_message_service {
.im_short_message_media,
.im_short_message_service {
color: #3a6d99;
}
.im_dialog_message_text {
.im_short_message_text {
color: #808080;
}
a.im_dialog:hover,
a.im_dialog_selected {
.im_dialog_message_text {
.im_short_message_text {
color: #698192;
}
}
@ -1312,8 +1312,8 @@ a.im_dialog_selected { @@ -1312,8 +1312,8 @@ a.im_dialog_selected {
a.im_dialog {
.im_dialog_chat_from_wrap,
.im_dialog_message_media,
.im_dialog_message_service,
.im_dialog_message_text,
.im_short_message_service,
.im_short_message_text,
.im_dialog_message {
color: #fff;
}
@ -1388,10 +1388,6 @@ a.im_dialog_selected { @@ -1388,10 +1388,6 @@ a.im_dialog_selected {
}
}
.im_dialog_service {
font-style: italic;
color: #999;
}
.im_dialog_message,
.im_dialog_peer {
overflow: hidden;
@ -2060,6 +2056,16 @@ img.im_message_document_thumb { @@ -2060,6 +2056,16 @@ img.im_message_document_thumb {
display: inline-block;
margin: 0 auto;
}
.im_service_message .im_service_message_pinned {
color: inherit;
font-weight: bold;
display: inline-block;
max-width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: middle;
}
.im_message_date,
.im_message_fwd_date {
@ -2186,8 +2192,8 @@ div.im_message_body { @@ -2186,8 +2192,8 @@ div.im_message_body {
.im_message_reply_loading {
padding: 7px 0 8px;
}
.im_reply_message_service,
.im_reply_message_media {
.im_message_reply_body .im_short_message_service,
.im_message_reply_body .im_short_message_media {
color: #999;
}
.im_message_reply_body {

22
app/partials/desktop/dialog.html

@ -57,27 +57,7 @@ @@ -57,27 +57,7 @@
</span>
</span>
<span class="im_dialog_message_media" ng-if="dialogMessage.media" ng-switch="dialogMessage.media._">
<span ng-switch-when="messageMediaPhoto" my-i18n="conversation_media_photo"></span>
<span ng-switch-when="messageMediaDocument" ng-switch="dialogMessage.media.document.type || false">
<span ng-switch-when="sticker">
<span ng-bind-html="dialogMessage.media.document.stickerEmoji"></span>
<my-i18n msgid="conversation_media_sticker"></my-i18n>
</span>
<span ng-switch-when="gif" my-i18n="conversation_media_gif"></span>
<span ng-switch-when="audio" my-i18n="conversation_media_audio"></span>
<span ng-switch-when="voice" my-i18n="conversation_media_audio"></span>
<span ng-switch-when="video" my-i18n="conversation_media_video"></span>
<span ng-switch-default ng-bind="dialogMessage.media.document.file_name"></span>
</span>
<span ng-switch-when="messageMediaGeo" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaVenue" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaContact" my-i18n="conversation_media_contact"></span>
</span>
<span class="im_dialog_message_service" ng-if="dialogMessage._ == 'messageService'" my-service-short-message="dialogMessage"></span>
<span class="im_dialog_message_text" ng-if="dialogMessage.message.length" ng-bind-html="dialogMessage.richMessage"></span>
<span my-short-message="dialogMessage"></span>
</div>
</div>

22
app/partials/desktop/forwarded_messages.html

@ -13,27 +13,7 @@ @@ -13,27 +13,7 @@
</div>
<div class="im_message_reply_body" ng-switch="singleMessage !== false">
<div ng-switch-when="true">
<span class="im_reply_message_media" ng-if="singleMessage.media" ng-switch="singleMessage.media._">
<span ng-switch-when="messageMediaPhoto" my-i18n="conversation_media_photo"></span>
<span ng-switch-when="messageMediaDocument" ng-switch="singleMessage.media.document.type || false">
<span ng-switch-when="sticker">
<span ng-bind-html="singleMessage.media.document.stickerEmoji"></span>
<my-i18n msgid="conversation_media_sticker"></my-i18n>
</span>
<span ng-switch-when="video" my-i18n="conversation_media_video"></span>
<span ng-switch-when="gif" my-i18n="conversation_media_gif"></span>
<span ng-switch-when="audio" my-i18n="conversation_media_audio"></span>
<span ng-switch-when="voice" my-i18n="conversation_media_audio"></span>
<span ng-switch-default ng-bind="singleMessage.media.document.file_name"></span>
</span>
<span ng-switch-when="messageMediaGeo" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaVenue" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaContact" my-i18n="conversation_media_contact"></span>
</span>
<span class="im_reply_message_service" ng-if="singleMessage._ == 'messageService'" my-service-short-message="singleMessage"></span>
<span class="im_reply_message_text" ng-if="singleMessage.message.length" ng-bind-html="singleMessage.richMessage"></span>
<span my-short-message="singleMessage"></span>
</div>
<div ng-switch-default>
<span class="im_reply_message_service">

5
app/partials/desktop/message_service.html

@ -30,6 +30,11 @@ @@ -30,6 +30,11 @@
<span ng-switch-when="messageActionChannelEditPhoto" my-i18n="message_service_changed_channel_photo"></span>
<span ng-switch-when="messageActionChannelDeletePhoto" my-i18n="message_service_removed_channel_photo"></span>
<span ng-switch-when="messageActionPinMessage" my-i18n="message_service_pinned_message">
<my-i18n-param name="message"><a class="im_service_message_pinned" my-pinned-message="historyMessage.reply_to_msg"></a></my-i18n-param>
</span>
<span ng-switch-default my-i18n="message_service_unsupported_action">
<my-i18n-param name="action"><span ng-bind="historyMessage.action._"></span></my-i18n-param>
</span>

1
app/partials/desktop/pinned_message.html

@ -0,0 +1 @@ @@ -0,0 +1 @@
<span ng-switch="pinnedMessage.loading"><span ng-switch-when="true" my-i18n="im_reply_loading"><my-i18n-param name="dots"><span my-loading-dots></span></my-i18n-param></span><span ng-switch-default my-short-message="pinnedMessage"></span></span>

23
app/partials/desktop/reply_message.html

@ -17,27 +17,6 @@ @@ -17,27 +17,6 @@
</div>
<div class="im_message_reply_body" ng-switch-default>
<span class="copyonly">&gt;&nbsp;</span>
<span class="im_reply_message_media" ng-if="replyMessage.media" ng-switch="replyMessage.media._">
<span ng-switch-when="messageMediaPhoto" my-i18n="conversation_media_photo"></span>
<span ng-switch-when="messageMediaDocument" ng-switch="dialogMessage.media.document.type || false">
<span ng-switch-when="sticker">
<span ng-bind-html="replyMessage.media.document.stickerEmoji"></span>
<my-i18n msgid="conversation_media_sticker"></my-i18n>
</span>
<span ng-switch-when="gif" my-i18n="conversation_media_gif"></span>
<span ng-switch-when="video" my-i18n="conversation_media_video"></span>
<span ng-switch-when="audio" my-i18n="conversation_media_audio"></span>
<span ng-switch-when="voice" my-i18n="conversation_media_audio"></span>
<span ng-switch-default ng-bind="replyMessage.media.document.file_name"></span>
</span>
<span ng-switch-when="messageMediaGeo" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaVenue" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaContact" my-i18n="conversation_media_contact"></span>
</span>
<span class="im_reply_message_service" ng-if="replyMessage._ == 'messageService'" my-service-short-message="replyMessage"></span>
<span class="im_reply_message_text" ng-if="replyMessage.message.length" ng-bind-html="replyMessage.richMessage"></span>
<span my-short-message="replyMessage"></span>
</div>
</div>

22
app/partials/desktop/dialog_service.html → app/partials/desktop/short_message.html

@ -1,4 +1,20 @@ @@ -1,4 +1,20 @@
<span ng-switch="message.action._">
<span class="im_short_message_media" ng-if="message.media" ng-switch="message.media._">
<span ng-switch-when="messageMediaPhoto" my-i18n="conversation_media_photo"></span>
<span ng-switch-when="messageMediaDocument" ng-switch="message.media.document.type || false">
<span ng-switch-when="sticker">
<span ng-bind-html="message.media.document.stickerEmoji"></span>
<my-i18n msgid="conversation_media_sticker"></my-i18n>
</span>
<span ng-switch-when="gif" my-i18n="conversation_media_gif"></span>
<span ng-switch-when="audio" my-i18n="conversation_media_audio"></span>
<span ng-switch-when="voice" my-i18n="conversation_media_audio"></span>
<span ng-switch-when="video" my-i18n="conversation_media_video"></span>
<span ng-switch-default ng-bind="message.media.document.file_name"></span>
</span>
<span ng-switch-when="messageMediaGeo" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaVenue" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaContact" my-i18n="conversation_media_contact"></span>
</span><span class="im_short_message_service" ng-if="message._ == 'messageService'" ng-switch="message.action._">
<span ng-switch-when="messageActionChatCreate" my-i18n="conversation_group_created"></span>
<span ng-switch-when="messageActionChatEditTitle" my-i18n="conversation_group_renamed"></span>
<span ng-switch-when="messageActionChatEditPhoto" my-i18n="conversation_group_photo_updated"></span>
@ -23,5 +39,5 @@ @@ -23,5 +39,5 @@
<span ng-switch-when="messageActionChannelCreate" my-i18n="conversation_created_channel"></span>
<span ng-switch-when="messageActionChannelEditTitle" my-i18n="conversation_changed_channel_name"></span>
<span ng-switch-when="messageActionChannelEditPhoto" my-i18n="conversation_changed_channel_photo"></span>
<span ng-switch-when="messageActionChannelDeletePhoto" my-i18n="conversation_removed_channel_photo"></span>
</span>
<span ng-switch-when="messageActionPinMessage" my-i18n="conversation_pinned_message"></span>
</span><span class="im_short_message_text" ng-if="message.message.length" ng-bind-html="message.richMessage"></span>

22
app/partials/mobile/dialog.html

@ -57,27 +57,7 @@ @@ -57,27 +57,7 @@
</span>
</span>
<span class="im_dialog_message_media" ng-if="dialogMessage.media" ng-switch="dialogMessage.media._">
<span ng-switch-when="messageMediaPhoto" my-i18n="conversation_media_photo"></span>
<span ng-switch-when="messageMediaDocument" ng-switch="dialogMessage.media.document.type || false">
<span ng-switch-when="sticker">
<span ng-bind-html="dialogMessage.media.document.stickerEmoji"></span>
<my-i18n msgid="conversation_media_sticker"></my-i18n>
</span>
<span ng-switch-when="video" my-i18n="conversation_media_video"></span>
<span ng-switch-when="gif" my-i18n="conversation_media_gif"></span>
<span ng-switch-when="audio" my-i18n="conversation_media_audio"></span>
<span ng-switch-when="voice" my-i18n="conversation_media_audio"></span>
<span ng-switch-default ng-bind="dialogMessage.media.document.file_name"></span>
</span>
<span ng-switch-when="messageMediaGeo" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaVenue" my-i18n="conversation_media_location"></span>
<span ng-switch-when="messageMediaContact" my-i18n="conversation_media_contact"></span>
</span>
<span class="im_dialog_message_service" ng-if="dialogMessage._ == 'messageService'" my-service-short-message="dialogMessage"></span>
<span class="im_dialog_message_text" ng-if="dialogMessage.message.length" ng-bind-html="dialogMessage.richMessage"></span>
<span my-short-message="dialogMessage"></span>
</div>
</div>

4
app/partials/mobile/message_service.html

@ -30,6 +30,10 @@ @@ -30,6 +30,10 @@
<span ng-switch-when="messageActionChannelEditPhoto" my-i18n="message_service_changed_channel_photo"></span>
<span ng-switch-when="messageActionChannelDeletePhoto" my-i18n="message_service_removed_channel_photo"></span>
<span ng-switch-when="messageActionPinMessage" my-i18n="message_service_pinned_message">
<my-i18n-param name="message"><a my-pinned-message="historyMessage.reply_to_msg"></a></my-i18n-param>
</span>
<span ng-switch-default my-i18n="message_service_unsupported_action">
<my-i18n-param name="action"><span ng-bind="historyMessage.action._"></span></my-i18n-param>
</span>

Loading…
Cancel
Save