Browse Source

Fixed mention without username

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

13
app/js/messages_manager.js

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

3
app/js/services.js

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

Loading…
Cancel
Save