Browse Source

Added self mentions highlight

Closes #683
Closes #656
master
Igor Zhukov 10 years ago
parent
commit
8ba0c063f9
  1. 5
      app/css/app.css
  2. 27
      app/js/services.js

5
app/css/app.css

@ -1844,6 +1844,11 @@ a.im_message_fwd_photo { @@ -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 {

27
app/js/services.js

@ -18,6 +18,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -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']) @@ -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']) @@ -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']) @@ -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']) @@ -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']) @@ -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']) @@ -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],
'<a href="#/im?p=',
'<a ' + attr + ' href="#/im?p=',
encodeURIComponent('@' + match[3]),
'">',
encodeEntities(match[2] + match[3]),

Loading…
Cancel
Save