Browse Source

Fixed mention without username

master
Igor Zhukov 9 years ago
parent
commit
efbe340c09
  1. 4
      app/js/lib/ng_utils.js
  2. 13
      app/js/messages_manager.js
  3. 3
      app/js/services.js

4
app/js/lib/ng_utils.js

@ -1433,7 +1433,6 @@ angular.module('izhukov.utils', [])
}) })
rawOffset -= 2 rawOffset -= 2
} else if (match[10]) { // custom mention } else if (match[10]) { // custom mention
console.log(match);
newText.push(text) newText.push(text)
entities.push({ entities.push({
_: 'messageEntityMentionName', _: 'messageEntityMentionName',
@ -1597,11 +1596,10 @@ angular.module('izhukov.utils', [])
break break
case 'messageEntityMentionName': case 'messageEntityMentionName':
if (!options.noLinks) { if (options.noLinks) {
skipEntity = true skipEntity = true
break break
} }
var username = entityText.substr(1)
html.push( html.push(
'<a href="#/im?p=u', '<a href="#/im?p=u',
encodeURIComponent(entity.user_id), encodeURIComponent(entity.user_id),

13
app/js/messages_manager.js

@ -1258,6 +1258,10 @@ angular.module('myApp.services')
if (!options.viaBotID) { if (!options.viaBotID) {
text = RichTextProcessor.parseMarkdown(text, entities) text = RichTextProcessor.parseMarkdown(text, entities)
} }
if (!text.length) {
return
}
var sendEntites = entities var sendEntites = entities
if (entities.length) { if (entities.length) {
sendEntites = angular.copy(entities) sendEntites = angular.copy(entities)
@ -1269,9 +1273,6 @@ angular.module('myApp.services')
}) })
} }
if (!text.length) {
return
}
var messageID = tempID-- var messageID = tempID--
var randomID = [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)] var randomID = [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]
@ -1319,7 +1320,7 @@ angular.module('myApp.services')
reply_to_msg_id: replyToMsgID, reply_to_msg_id: replyToMsgID,
via_bot_id: options.viaBotID, via_bot_id: options.viaBotID,
reply_markup: options.reply_markup, reply_markup: options.reply_markup,
entities: sendEntites, entities: entities,
views: asChannel && 1, views: asChannel && 1,
pending: true pending: true
} }
@ -1367,7 +1368,7 @@ angular.module('myApp.services')
id: options.resultID id: options.resultID
}, sentRequestOptions) }, sentRequestOptions)
} else { } else {
if (entities.length) { if (sendEntites.length) {
flags |= 8 flags |= 8
} }
apiPromise = MtpApiManager.invokeApi('messages.sendMessage', { apiPromise = MtpApiManager.invokeApi('messages.sendMessage', {
@ -1376,7 +1377,7 @@ angular.module('myApp.services')
message: text, message: text,
random_id: randomID, random_id: randomID,
reply_to_msg_id: AppMessagesIDsManager.getMessageLocalID(replyToMsgID), reply_to_msg_id: AppMessagesIDsManager.getMessageLocalID(replyToMsgID),
entities: entities entities: sendEntites
}, sentRequestOptions) }, sentRequestOptions)
} }
// console.log(flags, entities) // console.log(flags, entities)

3
app/js/services.js

@ -928,6 +928,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
function resolveUsername (username) { function resolveUsername (username) {
var searchUserName = SearchIndexManager.cleanUsername(username) var searchUserName = SearchIndexManager.cleanUsername(username)
if (searchUserName.match(/^\d+$/)) {
return qSync.when(false)
}
var foundUserID var foundUserID
var foundChatID, foundPeerID var foundChatID, foundPeerID
var foundUsername var foundUsername

Loading…
Cancel
Save