diff --git a/app/js/directives.js b/app/js/directives.js index 206b8e40..b3f4b868 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -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']) }) + .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 { diff --git a/app/js/lib/utils.js b/app/js/lib/utils.js index 707d39d9..b59eb0d8 100644 --- a/app/js/lib/utils.js +++ b/app/js/lib/utils.js @@ -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', diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index 9dbeb0a3..dd539882 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -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 @@ "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", diff --git a/app/less/app.less b/app/less/app.less index 4a9443dc..4532868e 100644 --- a/app/less/app.less +++ b/app/less/app.less @@ -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 { 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 { } } -.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 { 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 { .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 { diff --git a/app/partials/desktop/dialog.html b/app/partials/desktop/dialog.html index b20e7d51..5c692e8f 100644 --- a/app/partials/desktop/dialog.html +++ b/app/partials/desktop/dialog.html @@ -57,27 +57,7 @@ - - - - - - - - - - - - - - - - - - - - - + diff --git a/app/partials/desktop/forwarded_messages.html b/app/partials/desktop/forwarded_messages.html index 8f48af1d..450e83f7 100644 --- a/app/partials/desktop/forwarded_messages.html +++ b/app/partials/desktop/forwarded_messages.html @@ -13,27 +13,7 @@
- - - - - - - - - - - - - - - - - - - - - +
diff --git a/app/partials/desktop/message_service.html b/app/partials/desktop/message_service.html index 99d94ce3..aecccb90 100644 --- a/app/partials/desktop/message_service.html +++ b/app/partials/desktop/message_service.html @@ -30,6 +30,11 @@ + + + + + diff --git a/app/partials/desktop/pinned_message.html b/app/partials/desktop/pinned_message.html new file mode 100644 index 00000000..ef0535b5 --- /dev/null +++ b/app/partials/desktop/pinned_message.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/partials/desktop/reply_message.html b/app/partials/desktop/reply_message.html index ee7e6778..36302303 100644 --- a/app/partials/desktop/reply_message.html +++ b/app/partials/desktop/reply_message.html @@ -17,27 +17,6 @@
- - - - - - - - - - - - - - - - - - - - - - +
\ No newline at end of file diff --git a/app/partials/desktop/dialog_service.html b/app/partials/desktop/short_message.html similarity index 57% rename from app/partials/desktop/dialog_service.html rename to app/partials/desktop/short_message.html index bad19614..77cdb8d9 100644 --- a/app/partials/desktop/dialog_service.html +++ b/app/partials/desktop/short_message.html @@ -1,4 +1,20 @@ - + + + + + + + + + + + + + + + + + @@ -23,5 +39,5 @@ - - + + \ No newline at end of file diff --git a/app/partials/mobile/dialog.html b/app/partials/mobile/dialog.html index b142f388..5c692e8f 100644 --- a/app/partials/mobile/dialog.html +++ b/app/partials/mobile/dialog.html @@ -57,27 +57,7 @@ - - - - - - - - - - - - - - - - - - - - - + diff --git a/app/partials/mobile/message_service.html b/app/partials/mobile/message_service.html index 99d94ce3..f9e5410f 100644 --- a/app/partials/mobile/message_service.html +++ b/app/partials/mobile/message_service.html @@ -30,6 +30,10 @@ + + + +