Browse Source

Improved forwards and signature text

master
Igor Zhukov 7 years ago
parent
commit
f62ff6b161
  1. 25
      app/js/directives.js
  2. 2
      app/js/locales/en-us.json
  3. 3
      app/js/messages_manager.js
  4. 7
      app/js/services.js
  5. 3
      app/less/desktop.less
  6. 9
      app/partials/desktop/channel_modal.html
  7. 2
      app/partials/desktop/message.html
  8. 2
      app/partials/desktop/peer_select.html
  9. 9
      app/partials/mobile/channel_modal.html
  10. 2
      app/partials/mobile/message.html
  11. 2
      app/partials/mobile/peer_select.html

25
app/js/directives.js

@ -212,16 +212,14 @@ angular.module('myApp.directives', ['myApp.filters'])
} }
function updateMessageSignature ($scope, element, message) { 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() $('.im_message_sign', element).hide()
return return
} }
var scope = $scope.$new(true) var html = RichTextProcessor.wrapRichText(postAuthor, {noLinks: true, noLinebreaks: true})
scope.signID = message.signID $('.im_message_sign', element).html('<span class="im_message_sign_link">' + html.valueOf() + '</span>')
messageSignCompiled(scope, function (clonedElement) {
$('.im_message_sign', element).replaceWith(clonedElement)
})
} }
function updateMessageKeyboard ($scope, element, message) { function updateMessageKeyboard ($scope, element, message) {
@ -3004,7 +3002,7 @@ angular.module('myApp.directives', ['myApp.filters'])
participantsCount = chat.participants_count participantsCount = chat.participants_count
} }
update() update()
if (!chatID) { if (!chatID || AppChatsManager.isChannel(chatID) && participantsCount) {
return return
} }
AppProfileManager.getChatFull(chatID).then(function (chatFull) { 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 { return {
link: link link: link
} }
@ -3147,7 +3145,16 @@ angular.module('myApp.directives', ['myApp.filters'])
if (peerID > 0) { if (peerID > 0) {
AppUsersManager.openUser(peerID, override) AppUsersManager.openUser(peerID, override)
} else { } 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)
}
} }
}) })
} }

2
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}.", "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_title": "Select conversation",
"conversation_select_modal_contacts": "Contacts", "conversation_select_modal_chats_contacts": "Chats and contacts",
"conversation_one_selected": "{name1}", "conversation_one_selected": "{name1}",
"conversation_two_selected": "{name1} and {name2}", "conversation_two_selected": "{name1} and {name2}",
"conversation_many_selected": "{name1}, {name2} and {count} more", "conversation_many_selected": "{name1}, {name2} and {count} more",

3
app/js/messages_manager.js

@ -1322,13 +1322,12 @@ angular.module('myApp.services')
var fwdHeader = apiMessage.fwd_from var fwdHeader = apiMessage.fwd_from
if (fwdHeader) { if (fwdHeader) {
apiMessage.fwdFromID = fwdHeader.channel_id ? -fwdHeader.channel_id : fwdHeader.from_id apiMessage.fwdFromID = fwdHeader.channel_id ? -fwdHeader.channel_id : fwdHeader.from_id
apiMessage.fwdPostID = fwdHeader.channel_post
fwdHeader.date -= ServerTimeManager.serverTimeOffset fwdHeader.date -= ServerTimeManager.serverTimeOffset
} }
apiMessage.peerID = peerID apiMessage.peerID = peerID
apiMessage.fromID = apiMessage.pFlags.post ? peerID : apiMessage.from_id 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) { if (apiMessage.via_bot_id > 0) {
apiMessage.viaBotID = apiMessage.via_bot_id apiMessage.viaBotID = apiMessage.via_bot_id

7
app/js/services.js

@ -617,7 +617,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return return
} }
} }
if (apiChat.pFlags.channel && if (apiChat._ == 'channel' &&
apiChat.participants_count === undefined && apiChat.participants_count === undefined &&
result !== undefined && result !== undefined &&
result.participants_count) { result.participants_count) {
@ -773,6 +773,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var chatFull = angular.copy(fullChat) var chatFull = angular.copy(fullChat)
var chat = getChat(id) var chat = getChat(id)
console.warn(chat, chatFull)
if (!chatFull.participants_count) {
chatFull.participants_count = chat.participants_count
}
if (chatFull.participants && chatFull.participants._ == 'chatParticipants') { if (chatFull.participants && chatFull.participants._ == 'chatParticipants') {
MtpApiManager.getUserID().then(function (myID) { MtpApiManager.getUserID().then(function (myID) {
var isAdmin = chat.pFlags.creator || chat.pFlags.admins_enabled && chat.pFlags.admin var isAdmin = chat.pFlags.creator || chat.pFlags.admins_enabled && chat.pFlags.admin

3
app/less/desktop.less

@ -1109,7 +1109,8 @@ a.peer_select_modal_share_link {
.im_message_fwd_author_wrap, .im_message_fwd_author_wrap,
.im_message_text, .im_message_text,
.im_message_media { .im_message_media,
.im_message_sign {
margin-left: 52px; margin-left: 52px;
} }
} }

9
app/partials/desktop/channel_modal.html

@ -21,10 +21,15 @@
</div> </div>
<div class="peer_modal_profile"> <div class="peer_modal_profile">
<div class="peer_modal_profile_name" my-peer-link="-chatFull.chat.id" verified="true"></div> <div class="peer_modal_profile_name" my-peer-link="-chatFull.chat.id" verified="true"></div>
<div class="peer_modal_profile_description" ng-if="chatFull.participants_count > 0"> <div class="peer_modal_profile_description" ng-if="chatFull.participants_count > 0" ng-switch="isMegagroup">
<ng-pluralize count="chatFull.participants_count" <ng-pluralize ng-switch-when="true"
count="chatFull.participants_count"
when="group_modal_pluralize_participants"> when="group_modal_pluralize_participants">
</ng-pluralize> </ng-pluralize>
<ng-pluralize ng-switch-default
count="chatFull.participants_count"
when="group_modal_pluralize_subscribers">
</ng-pluralize>
</div> </div>
</div> </div>
</div> </div>

2
app/partials/desktop/message.html

@ -57,7 +57,7 @@
<span class="copyonly"><span my-i18n="message_forwarded_message"></span>:&nbsp;</span> <span class="copyonly"><span my-i18n="message_forwarded_message"></span>:&nbsp;</span>
<a class="im_message_fwd_photo pull-left" my-peer-photolink="::historyMessage.fwdFromID" img-class="im_message_fwd_photo"></a> <a class="im_message_fwd_photo pull-left" my-peer-photolink="::historyMessage.fwdFromID" img-class="im_message_fwd_photo"></a>
<div class="im_message_fwd_author_wrap"> <div class="im_message_fwd_author_wrap">
<a class="im_message_fwd_author" my-peer-link="historyMessage.fwdFromID"></a><a ng-if="::historyMessage.viaBotID" class="im_message_fwd_via" ng-click="selectInlineBot(historyMessage.viaBotID, $event)"><span class="copyonly">&nbsp;</span><span my-i18n="message_via_bot"><my-i18n-param name="bot"><span class="im_message_fwd_author" my-peer-link="historyMessage.viaBotID" username="true" no-watch="true"></span></my-i18n-param></span></a><span class="copyonly">&nbsp;[</span><span class="im_message_fwd_date" ng-bind="::historyMessage.fwd_from.date | dateOrTime"></span><span class="copyonly">]&nbsp;</span> <a class="im_message_fwd_author" my-peer-link="historyMessage.fwdFromID" post-id="historyMessage.fwdPostID"></a><a ng-if="::historyMessage.viaBotID" class="im_message_fwd_via" ng-click="selectInlineBot(historyMessage.viaBotID, $event)"><span class="copyonly">&nbsp;</span><span my-i18n="message_via_bot"><my-i18n-param name="bot"><span class="im_message_fwd_author" my-peer-link="historyMessage.viaBotID" username="true" no-watch="true"></span></my-i18n-param></span></a><span class="copyonly">&nbsp;[</span><span class="im_message_fwd_date" ng-bind="::historyMessage.fwd_from.date | dateOrTime"></span><span class="copyonly">]&nbsp;</span>
<span class="im_message_views_inline" ng-if="::historyMessage.views > 0"> <span class="im_message_views_inline" ng-if="::historyMessage.views > 0">
<i class="icon-message-views"></i><span class="im_message_views_cnt" my-message-views="historyMessage.mid"></span> <i class="icon-message-views"></i><span class="im_message_views_cnt" my-message-views="historyMessage.mid"></span>
</span> </span>

2
app/partials/desktop/peer_select.html

@ -27,7 +27,7 @@
<li class="im_dialog_wrap" my-dialog dialog-message="dialogMessage" ng-repeat="dialogMessage in dialogs track by dialogMessage.peerID" ng-class="{active: selectedPeers[dialogMessage.peerID] !== undefined}"></li> <li class="im_dialog_wrap" my-dialog dialog-message="dialogMessage" ng-repeat="dialogMessage in dialogs track by dialogMessage.peerID" ng-class="{active: selectedPeers[dialogMessage.peerID] !== undefined}"></li>
</ul> </ul>
<div class="im_dialogs_contacts_wrap" ng-show="myResults.length > 0"> <div class="im_dialogs_contacts_wrap" ng-show="myResults.length > 0">
<h5 my-i18n="conversation_select_modal_contacts"></h5> <h5 my-i18n="conversation_select_modal_chats_contacts"></h5>
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li class="im_dialog_wrap" ng-repeat="myResult in myResults track by myResult.id" ng-class="{active: selectedPeers[myResult.id] !== undefined}"> <li class="im_dialog_wrap" ng-repeat="myResult in myResults track by myResult.id" ng-class="{active: selectedPeers[myResult.id] !== undefined}">
<a class="im_dialog" ng-click="dialogSelect(myResult.peerString)"> <a class="im_dialog" ng-click="dialogSelect(myResult.peerString)">

9
app/partials/mobile/channel_modal.html

@ -53,10 +53,15 @@
<div class="mobile_user_modal_info_wrap clearfix"> <div class="mobile_user_modal_info_wrap clearfix">
<h4 class="mobile_user_modal_header" my-peer-link="-chatFull.chat.id"></h4> <h4 class="mobile_user_modal_header" my-peer-link="-chatFull.chat.id"></h4>
<p class="mobile_user_modal_status" ng-if="chatFull.participants_count > 0"> <p class="mobile_user_modal_status" ng-if="chatFull.participants_count > 0" ng-switch="isMegagroup">
<ng-pluralize count="chatFull.participants_count" <ng-pluralize ng-switch-when="true"
count="chatFull.participants_count"
when="group_modal_pluralize_participants"> when="group_modal_pluralize_participants">
</ng-pluralize> </ng-pluralize>
<ng-pluralize ng-switch-default
count="chatFull.participants_count"
when="group_modal_pluralize_subscribers">
</ng-pluralize>
</p> </p>
</div> </div>

2
app/partials/mobile/message.html

@ -54,7 +54,7 @@
<div ng-if="::!!historyMessage.fwdFromID &amp;&amp; !historyMessage.media" class="im_message_fwd_header" ng-switch="!!historyMessage.viaBotID" my-i18n> <div ng-if="::!!historyMessage.fwdFromID &amp;&amp; !historyMessage.media" class="im_message_fwd_header" ng-switch="!!historyMessage.viaBotID" my-i18n>
<span ng-switch-when="true" my-i18n-format="message_forwarded_via_message_mobile"></span> <span ng-switch-when="true" my-i18n-format="message_forwarded_via_message_mobile"></span>
<span ng-switch-default my-i18n-format="message_forwarded_message_mobile"></span> <span ng-switch-default my-i18n-format="message_forwarded_message_mobile"></span>
<my-i18n-param name="from"><a class="im_message_fwd_author" my-peer-link="historyMessage.fwdFromID" no-watch="true"></a></my-i18n-param> <my-i18n-param name="from"><a class="im_message_fwd_author" my-peer-link="historyMessage.fwdFromID" no-watch="true" post-id="historyMessage.fwdPostID"></a></my-i18n-param>
<my-i18n-param name="bot"><a class="im_message_fwd_author" my-peer-link="historyMessage.viaBotID" username="true" no-watch="true"></a></my-i18n-param> <my-i18n-param name="bot"><a class="im_message_fwd_author" my-peer-link="historyMessage.viaBotID" username="true" no-watch="true"></a></my-i18n-param>
</div> </div>

2
app/partials/mobile/peer_select.html

@ -43,7 +43,7 @@
<li class="im_dialog_wrap" my-dialog dialog-message="dialogMessage" ng-repeat="dialogMessage in dialogs track by dialogMessage.peerID"></li> <li class="im_dialog_wrap" my-dialog dialog-message="dialogMessage" ng-repeat="dialogMessage in dialogs track by dialogMessage.peerID"></li>
</ul> </ul>
<div class="im_dialogs_contacts_wrap" ng-show="myResults.length > 0"> <div class="im_dialogs_contacts_wrap" ng-show="myResults.length > 0">
<h5 my-i18n="conversation_select_modal_contacts"></h5> <h5 my-i18n="conversation_select_modal_chats_contacts"></h5>
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li class="im_dialog_wrap" ng-repeat="myResult in myResults track by myResult.id" ng-class="{active: curDialog.peerID == myResult.id}"> <li class="im_dialog_wrap" ng-repeat="myResult in myResults track by myResult.id" ng-class="{active: curDialog.peerID == myResult.id}">
<a class="im_dialog" ng-click="dialogSelect(myResult.peerString)"> <a class="im_dialog" ng-click="dialogSelect(myResult.peerString)">

Loading…
Cancel
Save