Browse Source

Fixed entities without username

master
Igor Zhukov 8 years ago
parent
commit
94eaf320d4
  1. 5
      app/js/lib/ng_utils.js
  2. 18
      app/js/messages_manager.js

5
app/js/lib/ng_utils.js

@ -1391,7 +1391,7 @@ angular.module('izhukov.utils', []) @@ -1391,7 +1391,7 @@ angular.module('izhukov.utils', [])
}
function parseMarkdown (text, entities) {
if (text.indexOf('`') == -1) {
if (text.indexOf('`') == -1 && text.indexOf('@') == -1) {
return text.trim()
}
var raw = text
@ -1433,6 +1433,7 @@ angular.module('izhukov.utils', []) @@ -1433,6 +1433,7 @@ angular.module('izhukov.utils', [])
})
rawOffset -= 2
} else if (match[10]) { // custom mention
console.log(match);
newText.push(text)
entities.push({
_: 'messageEntityMentionName',
@ -1455,6 +1456,8 @@ angular.module('izhukov.utils', []) @@ -1455,6 +1456,8 @@ angular.module('izhukov.utils', [])
if (!entities.length) {
newText = newText.trim()
}
console.warn(dT(), newText, entities);
// throw new Error(11);
return newText
}

18
app/js/messages_manager.js

@ -1258,12 +1258,16 @@ angular.module('myApp.services') @@ -1258,12 +1258,16 @@ angular.module('myApp.services')
if (!options.viaBotID) {
text = RichTextProcessor.parseMarkdown(text, entities)
}
angular.forEach(entities, function (entity) {
if (entity._ == 'messageEntityMentionName') {
entity._ = 'inputMessageEntityMentionName'
entity.user_id = AppUsersManager.getUserInput(entity.user_id)
}
})
var sendEntites = entities
if (entities.length) {
sendEntites = angular.copy(entities)
angular.forEach(sendEntites, function (entity) {
if (entity._ == 'messageEntityMentionName') {
entity._ = 'inputMessageEntityMentionName'
entity.user_id = AppUsersManager.getUserInput(entity.user_id)
}
})
}
if (!text.length) {
return
@ -1315,7 +1319,7 @@ angular.module('myApp.services') @@ -1315,7 +1319,7 @@ angular.module('myApp.services')
reply_to_msg_id: replyToMsgID,
via_bot_id: options.viaBotID,
reply_markup: options.reply_markup,
entities: entities,
entities: sendEntites,
views: asChannel && 1,
pending: true
}

Loading…
Cancel
Save