From 8ba0c063f944b23a7d402bf5934174d5c0913dbe Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Thu, 19 Mar 2015 21:30:01 +0300 Subject: [PATCH] Added self mentions highlight Closes #683 Closes #656 --- app/css/app.css | 5 +++++ app/js/services.js | 27 +++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/css/app.css b/app/css/app.css index 3a7ed48a..272a87a9 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -1844,6 +1844,11 @@ a.im_message_fwd_photo { word-wrap: break-word; line-height: 150%; } +.im_message_mymention { + background: #FFF8CC; + /*border-bottom: 1px solid #FFE222;*/ + /*font-weight: bold;*/ +} .im_history_not_selected, .im_history_empty { diff --git a/app/js/services.js b/app/js/services.js index 74034b29..812414f4 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -18,6 +18,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) contactsFillPromise, contactsList, contactsIndex = SearchIndexManager.createIndex(), + myID, serverTimeOffset = 0; Storage.get('server_time_offset').then(function (to) { @@ -25,6 +26,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) serverTimeOffset = to; } }); + MtpApiManager.getUserID().then(function (id) { + myID = id; + }); function fillContacts () { if (contactsFillPromise) { @@ -171,6 +175,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return users[id] || {id: id, deleted: true, num: 1}; } + function getSelf() { + return getUser(myID); + } + function hasUser(id) { return angular.isObject(users[id]); } @@ -424,6 +432,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) saveApiUsers: saveApiUsers, saveApiUser: saveApiUser, getUser: getUser, + getSelf: getSelf, getUserInput: getUserInput, setUserStatus: setUserStatus, forceUserOnline: forceUserOnline, @@ -2031,6 +2040,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) if (!Config.Navigator.mobile) { options.extractUrlEmbed = true; } + if (message.flags & 16) { + var user = AppUsersManager.getSelf(); + if (user) { + options.highlightUsername = user.username; + } + } message.richMessage = RichTextProcessor.wrapRichText(message.message, options); if (options.extractedUrlEmbed) { message.richUrlEmbed = options.extractedUrlEmbed; @@ -2240,7 +2255,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) notification.title = RichTextProcessor.wrapPlainText(notification.title); notification.onclick = function () { - $rootScope.$broadcast('history_focus', {peerString: peerString}); + $rootScope.$broadcast('history_focus', { + peerString: peerString, + messageID: message.flags & 16 ? message.id : 0, + }); }; notification.message = notificationMessage; @@ -3843,9 +3861,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) if (match[3]) { // telegram.me links if (!options.noLinks) { + var attr = ''; + if (options.highlightUsername == match[3] && + match[2] == '@') { + attr = 'class="im_message_mymention"'; + } html.push( match[1], - '', encodeEntities(match[2] + match[3]),