|
|
@ -2650,6 +2650,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getDifference () { |
|
|
|
function getDifference () { |
|
|
|
|
|
|
|
console.trace(dT(), 'Get full diff'); |
|
|
|
if (!updatesState.syncLoading) { |
|
|
|
if (!updatesState.syncLoading) { |
|
|
|
updatesState.syncLoading = true; |
|
|
|
updatesState.syncLoading = true; |
|
|
|
updatesState.pendingSeqUpdates = {}; |
|
|
|
updatesState.pendingSeqUpdates = {}; |
|
|
@ -2721,12 +2722,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
channelState.syncLoading = true; |
|
|
|
channelState.syncLoading = true; |
|
|
|
channelState.pendingPtsUpdates = []; |
|
|
|
channelState.pendingPtsUpdates = []; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (channelState.syncPending) { |
|
|
|
|
|
|
|
clearTimeout(channelState.syncPending.timeout); |
|
|
|
|
|
|
|
channelState.syncPending = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log(dT(), 'Get channel diff', AppChatsManager.getChat(channelID), channelState.pts); |
|
|
|
MtpApiManager.invokeApi('updates.getChannelDifference', { |
|
|
|
MtpApiManager.invokeApi('updates.getChannelDifference', { |
|
|
|
channel: AppChatsManager.getChannelInput(channelID), |
|
|
|
channel: AppChatsManager.getChannelInput(channelID), |
|
|
|
filter: {_: 'channelMessagesFilterEmpty'}, |
|
|
|
filter: {_: 'channelMessagesFilterEmpty'}, |
|
|
|
pts: channelState.pts, |
|
|
|
pts: channelState.pts, |
|
|
|
limit: 10 |
|
|
|
limit: 30 |
|
|
|
}).then(function (differenceResult) { |
|
|
|
}).then(function (differenceResult) { |
|
|
|
|
|
|
|
console.log(dT(), 'channel diff result', differenceResult); |
|
|
|
channelState.pts = differenceResult.pts; |
|
|
|
channelState.pts = differenceResult.pts; |
|
|
|
|
|
|
|
|
|
|
|
if (differenceResult._ == 'updates.channelDifferenceEmpty') { |
|
|
|
if (differenceResult._ == 'updates.channelDifferenceEmpty') { |
|
|
@ -2809,12 +2816,16 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
channelID = update.channel_id; |
|
|
|
channelID = update.channel_id; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// if (channelID) {
|
|
|
|
|
|
|
|
// console.log(dT(), channelID, update.pts, update);
|
|
|
|
|
|
|
|
// }
|
|
|
|
if (channelID && !AppChatsManager.hasChat(channelID)) { |
|
|
|
if (channelID && !AppChatsManager.hasChat(channelID)) { |
|
|
|
|
|
|
|
console.log(dT(), 'skip update, missing channel', channelID, update); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
var curState = channelID ? getChannelState(channelID, update.pts) : updatesState; |
|
|
|
var curState = channelID ? getChannelState(channelID, update.pts) : updatesState; |
|
|
|
|
|
|
|
|
|
|
|
// console.log('process', channelID, curState, update);
|
|
|
|
console.log(dT(), 'process', channelID, curState, update); |
|
|
|
|
|
|
|
|
|
|
|
if (curState.syncLoading) { |
|
|
|
if (curState.syncLoading) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -2840,7 +2851,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
if (update.pts) { |
|
|
|
if (update.pts) { |
|
|
|
var newPts = curState.pts + (update.pts_count || 0); |
|
|
|
var newPts = curState.pts + (update.pts_count || 0); |
|
|
|
if (newPts < update.pts) { |
|
|
|
if (newPts < update.pts) { |
|
|
|
console.log(dT(), 'Pts hole', curState, update); |
|
|
|
console.warn(dT(), 'Pts hole', curState, update, channelID && AppChatsManager.getChat(channelID)); |
|
|
|
curState.pendingPtsUpdates.push(update); |
|
|
|
curState.pendingPtsUpdates.push(update); |
|
|
|
if (!curState.syncPending) { |
|
|
|
if (!curState.syncPending) { |
|
|
|
curState.syncPending = { |
|
|
|
curState.syncPending = { |
|
|
@ -2860,6 +2871,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
curState.pts = update.pts; |
|
|
|
curState.pts = update.pts; |
|
|
|
popPts = true; |
|
|
|
popPts = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (channelID && options.date && updatesState.date < options.date) { |
|
|
|
|
|
|
|
updatesState.date = options.date; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!channelID && options.seq > 0) { |
|
|
|
else if (!channelID && options.seq > 0) { |
|
|
|
var seq = options.seq; |
|
|
|
var seq = options.seq; |
|
|
|