Browse Source

Improved mtproto and handling updates

master
Igor Zhukov 7 years ago
parent
commit
623d7535cc
  1. 4
      app/js/lib/mtproto.js
  2. 22
      app/js/services.js

4
app/js/lib/mtproto.js

@ -1545,7 +1545,9 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
break break
} }
case 'msg_new_detailed_info': case 'msg_new_detailed_info':
// this.ackMessage(message.answer_msg_id) if (this.pendingAcks.indexOf(message.answer_msg_id)) {
break
}
this.reqResendMessage(message.answer_msg_id) this.reqResendMessage(message.answer_msg_id)
break break

22
app/js/services.js

@ -3095,6 +3095,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
curState.pendingPtsUpdates.sort(function (a, b) { curState.pendingPtsUpdates.sort(function (a, b) {
return a.pts - b.pts return a.pts - b.pts
}) })
// console.log(dT(), 'pop update', channelID, curState.pendingPtsUpdates)
var curPts = curState.pts var curPts = curState.pts
var goodPts = false var goodPts = false
@ -3387,7 +3388,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
if (update._ == 'updateChannelTooLong') { if (update._ == 'updateChannelTooLong') {
getChannelDifference(channelID) if (!curState.lastPtsUpdateTime ||
curState.lastPtsUpdateTime < tsNow() - 10000) {
// console.trace(dT(), 'channel too long, get diff', channelID, update)
getChannelDifference(channelID)
}
return false return false
} }
@ -3398,12 +3403,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var message = update.message var message = update.message
var toPeerID = AppPeersManager.getPeerID(message.to_id) var toPeerID = AppPeersManager.getPeerID(message.to_id)
var fwdHeader = message.fwd_from || {} var fwdHeader = message.fwd_from || {}
if (message.from_id && !AppUsersManager.hasUser(message.from_id, message.pFlags.post) || var reason = false
fwdHeader.from_id && !AppUsersManager.hasUser(fwdHeader.from_id, !!fwdHeader.channel_id) || if (message.from_id && !AppUsersManager.hasUser(message.from_id, message.pFlags.post/* || channelID*/) && (reason = 'author') ||
fwdHeader.channel_id && !AppChatsManager.hasChat(fwdHeader.channel_id, true) || fwdHeader.from_id && !AppUsersManager.hasUser(fwdHeader.from_id, !!fwdHeader.channel_id) && (reason = 'fwdAuthor') ||
toPeerID > 0 && !AppUsersManager.hasUser(toPeerID) || fwdHeader.channel_id && !AppChatsManager.hasChat(fwdHeader.channel_id, true) && (reason = 'fwdChannel') ||
toPeerID < 0 && !AppChatsManager.hasChat(-toPeerID)) { toPeerID > 0 && !AppUsersManager.hasUser(toPeerID) && (reason = 'toPeer User') ||
console.warn(dT(), 'Not enough data for message update', message) toPeerID < 0 && !AppChatsManager.hasChat(-toPeerID) && (reason = 'toPeer Chat')) {
console.warn(dT(), 'Not enough data for message update', toPeerID, reason, message)
if (channelID && AppChatsManager.hasChat(channelID)) { if (channelID && AppChatsManager.hasChat(channelID)) {
getChannelDifference(channelID) getChannelDifference(channelID)
} else { } else {
@ -3442,6 +3448,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if (update.pts > curState.pts) { if (update.pts > curState.pts) {
curState.pts = update.pts curState.pts = update.pts
popPts = true popPts = true
curState.lastPtsUpdateTime = tsNow()
} }
else if (update.pts_count) { else if (update.pts_count) {
// console.warn(dT(), 'Duplicate update', update) // console.warn(dT(), 'Duplicate update', update)

Loading…
Cancel
Save