|
|
@ -1006,17 +1006,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
offset = 0, |
|
|
|
offset = 0, |
|
|
|
offsetNotFound = false, |
|
|
|
offsetNotFound = false, |
|
|
|
unreadOffset = false, |
|
|
|
unreadOffset = false, |
|
|
|
unreadSkip = false, |
|
|
|
unreadSkip = false; |
|
|
|
resultPending = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prerendered = prerendered ? Math.min(50, prerendered) : 0; |
|
|
|
prerendered = prerendered ? Math.min(50, prerendered) : 0; |
|
|
|
|
|
|
|
|
|
|
|
if (historyStorage === undefined) { |
|
|
|
if (historyStorage === undefined) { |
|
|
|
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []}; |
|
|
|
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []}; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!maxID && historyStorage.pending.length) { |
|
|
|
|
|
|
|
resultPending = historyStorage.pending.slice(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!limit && !maxID) { |
|
|
|
if (!limit && !maxID) { |
|
|
|
var foundDialog = getDialogByPeerID(peerID); |
|
|
|
var foundDialog = getDialogByPeerID(peerID); |
|
|
@ -1056,9 +1052,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
limit = limit || (offset ? 20 : (prerendered || 5)); |
|
|
|
limit = limit || (offset ? 20 : (prerendered || 5)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var history = historyStorage.history.slice(offset, offset + limit); |
|
|
|
|
|
|
|
if (!maxID && historyStorage.pending.length) { |
|
|
|
|
|
|
|
history = historyStorage.pending.slice().concat(history); |
|
|
|
|
|
|
|
} |
|
|
|
return $q.when({ |
|
|
|
return $q.when({ |
|
|
|
count: historyStorage.count, |
|
|
|
count: historyStorage.count, |
|
|
|
history: resultPending.concat(historyStorage.history.slice(offset, offset + limit)), |
|
|
|
history: history, |
|
|
|
unreadOffset: unreadOffset, |
|
|
|
unreadOffset: unreadOffset, |
|
|
|
unreadSkip: unreadSkip |
|
|
|
unreadSkip: unreadSkip |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1082,10 +1082,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
angular.forEach(historyResult.messages, function (message) { |
|
|
|
angular.forEach(historyResult.messages, function (message) { |
|
|
|
history.push(message.id); |
|
|
|
history.push(message.id); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
if (!maxID && historyStorage.pending.length) { |
|
|
|
|
|
|
|
history = historyStorage.pending.slice().concat(history); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
count: historyStorage.count, |
|
|
|
count: historyStorage.count, |
|
|
|
history: resultPending.concat(history), |
|
|
|
history: history, |
|
|
|
unreadOffset: unreadOffset, |
|
|
|
unreadOffset: unreadOffset, |
|
|
|
unreadSkip: unreadSkip |
|
|
|
unreadSkip: unreadSkip |
|
|
|
}; |
|
|
|
}; |
|
|
@ -1102,9 +1105,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var history = historyStorage.history.slice(offset, offset + limit); |
|
|
|
|
|
|
|
if (!maxID && historyStorage.pending.length) { |
|
|
|
|
|
|
|
history = historyStorage.pending.slice().concat(history); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
count: historyStorage.count, |
|
|
|
count: historyStorage.count, |
|
|
|
history: resultPending.concat(historyStorage.history.slice(offset, offset + limit)), |
|
|
|
history: history, |
|
|
|
unreadOffset: unreadOffset, |
|
|
|
unreadOffset: unreadOffset, |
|
|
|
unreadSkip: unreadSkip |
|
|
|
unreadSkip: unreadSkip |
|
|
|
}; |
|
|
|
}; |
|
|
|