From f62ff6b1611b9748d77f535c625d4a8ed95e5f9f Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Wed, 27 Dec 2017 23:47:13 +0400 Subject: [PATCH] Improved forwards and signature text --- app/js/directives.js | 25 ++++++++++++++++--------- app/js/locales/en-us.json | 2 +- app/js/messages_manager.js | 3 +-- app/js/services.js | 7 ++++++- app/less/desktop.less | 3 ++- app/partials/desktop/channel_modal.html | 9 +++++++-- app/partials/desktop/message.html | 2 +- app/partials/desktop/peer_select.html | 2 +- app/partials/mobile/channel_modal.html | 9 +++++++-- app/partials/mobile/message.html | 2 +- app/partials/mobile/peer_select.html | 2 +- 11 files changed, 44 insertions(+), 22 deletions(-) diff --git a/app/js/directives.js b/app/js/directives.js index 888a600f..bc56c10e 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -212,16 +212,14 @@ angular.module('myApp.directives', ['myApp.filters']) } function updateMessageSignature ($scope, element, message) { - if (!message.signID) { + var postAuthor = message.post_author || (message.fwd_from && message.fwd_from.post_author) + if (!postAuthor) { $('.im_message_sign', element).hide() return } - var scope = $scope.$new(true) - scope.signID = message.signID - messageSignCompiled(scope, function (clonedElement) { - $('.im_message_sign', element).replaceWith(clonedElement) - }) + var html = RichTextProcessor.wrapRichText(postAuthor, {noLinks: true, noLinebreaks: true}) + $('.im_message_sign', element).html('' + html.valueOf() + '') } function updateMessageKeyboard ($scope, element, message) { @@ -3004,7 +3002,7 @@ angular.module('myApp.directives', ['myApp.filters']) participantsCount = chat.participants_count } update() - if (!chatID) { + if (!chatID || AppChatsManager.isChannel(chatID) && participantsCount) { return } AppProfileManager.getChatFull(chatID).then(function (chatFull) { @@ -3104,7 +3102,7 @@ angular.module('myApp.directives', ['myApp.filters']) } }) - .directive('myPeerLink', function (AppChatsManager, AppUsersManager) { + .directive('myPeerLink', function ($rootScope, AppChatsManager, AppUsersManager, AppMessagesIDsManager) { return { link: link } @@ -3147,7 +3145,16 @@ angular.module('myApp.directives', ['myApp.filters']) if (peerID > 0) { AppUsersManager.openUser(peerID, override) } else { - AppChatsManager.openChat(-peerID) + var chatID = -peerID + var postID = $scope.$eval(attrs.postId) + if (postID) { + $rootScope.$broadcast('history_focus', { + peerString: AppChatsManager.getChatString(chatID), + messageID: AppMessagesIDsManager.getFullMessageID(parseInt(postID), chatID) + }) + } else { + AppChatsManager.openChat(chatID) + } } }) } diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index 5ff726d8..fb917f70 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -609,7 +609,7 @@ "message_attach_unsupported": "The message is not supported on your version of Telegram Web. Update the app to view: {link}.", "conversation_select_modal_title": "Select conversation", - "conversation_select_modal_contacts": "Contacts", + "conversation_select_modal_chats_contacts": "Chats and contacts", "conversation_one_selected": "{name1}", "conversation_two_selected": "{name1} and {name2}", "conversation_many_selected": "{name1}, {name2} and {count} more", diff --git a/app/js/messages_manager.js b/app/js/messages_manager.js index c16164c8..dd359785 100644 --- a/app/js/messages_manager.js +++ b/app/js/messages_manager.js @@ -1322,13 +1322,12 @@ angular.module('myApp.services') var fwdHeader = apiMessage.fwd_from if (fwdHeader) { apiMessage.fwdFromID = fwdHeader.channel_id ? -fwdHeader.channel_id : fwdHeader.from_id + apiMessage.fwdPostID = fwdHeader.channel_post fwdHeader.date -= ServerTimeManager.serverTimeOffset } apiMessage.peerID = peerID apiMessage.fromID = apiMessage.pFlags.post ? peerID : apiMessage.from_id - apiMessage.signID = apiMessage.pFlags.post && apiMessage.from_id || - fwdHeader && fwdHeader.channel_id && fwdHeader.from_id if (apiMessage.via_bot_id > 0) { apiMessage.viaBotID = apiMessage.via_bot_id diff --git a/app/js/services.js b/app/js/services.js index c556597a..adbd7c81 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -617,7 +617,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return } } - if (apiChat.pFlags.channel && + if (apiChat._ == 'channel' && apiChat.participants_count === undefined && result !== undefined && result.participants_count) { @@ -773,6 +773,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) var chatFull = angular.copy(fullChat) var chat = getChat(id) + console.warn(chat, chatFull) + if (!chatFull.participants_count) { + chatFull.participants_count = chat.participants_count + } + if (chatFull.participants && chatFull.participants._ == 'chatParticipants') { MtpApiManager.getUserID().then(function (myID) { var isAdmin = chat.pFlags.creator || chat.pFlags.admins_enabled && chat.pFlags.admin diff --git a/app/less/desktop.less b/app/less/desktop.less index bc5ac39a..45341938 100644 --- a/app/less/desktop.less +++ b/app/less/desktop.less @@ -1109,7 +1109,8 @@ a.peer_select_modal_share_link { .im_message_fwd_author_wrap, .im_message_text, - .im_message_media { + .im_message_media, + .im_message_sign { margin-left: 52px; } } diff --git a/app/partials/desktop/channel_modal.html b/app/partials/desktop/channel_modal.html index bc86b76c..3d05bb8a 100644 --- a/app/partials/desktop/channel_modal.html +++ b/app/partials/desktop/channel_modal.html @@ -21,10 +21,15 @@
-
- + + +
diff --git a/app/partials/desktop/message.html b/app/partials/desktop/message.html index e5258350..b9265382 100644 --- a/app/partials/desktop/message.html +++ b/app/partials/desktop/message.html @@ -57,7 +57,7 @@
-   [ +   [ diff --git a/app/partials/desktop/peer_select.html b/app/partials/desktop/peer_select.html index 18f427f9..f0662126 100644 --- a/app/partials/desktop/peer_select.html +++ b/app/partials/desktop/peer_select.html @@ -27,7 +27,7 @@