|
|
|
@ -901,7 +901,7 @@ angular.module('myApp.services', [])
@@ -901,7 +901,7 @@ angular.module('myApp.services', [])
|
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function getHistory (inputPeer, maxID, limit, backLimit) { |
|
|
|
|
function getHistory (inputPeer, maxID, limit, backLimit, prerendered) { |
|
|
|
|
var peerID = AppPeersManager.getPeerID(inputPeer), |
|
|
|
|
historyStorage = historiesStorage[peerID], |
|
|
|
|
offset = 0, |
|
|
|
@ -910,6 +910,8 @@ angular.module('myApp.services', [])
@@ -910,6 +910,8 @@ angular.module('myApp.services', [])
|
|
|
|
|
unreadSkip = false, |
|
|
|
|
resultPending = []; |
|
|
|
|
|
|
|
|
|
prerendered = prerendered ? Math.min(50, prerendered) : 0; |
|
|
|
|
|
|
|
|
|
if (historyStorage === undefined) { |
|
|
|
|
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []}; |
|
|
|
|
} |
|
|
|
@ -926,7 +928,7 @@ angular.module('myApp.services', [])
@@ -926,7 +928,7 @@ angular.module('myApp.services', [])
|
|
|
|
|
unreadOffset = 6; |
|
|
|
|
offset = unreadCount - unreadOffset; |
|
|
|
|
} else { |
|
|
|
|
limit = Math.max(10, unreadCount + 2); |
|
|
|
|
limit = Math.max(10, prerendered, unreadCount + 2); |
|
|
|
|
unreadOffset = unreadCount; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -950,9 +952,8 @@ angular.module('myApp.services', [])
@@ -950,9 +952,8 @@ angular.module('myApp.services', [])
|
|
|
|
|
offset = Math.max(0, offset - backLimit); |
|
|
|
|
limit += backLimit; |
|
|
|
|
} else { |
|
|
|
|
limit = limit || (offset ? 20 : 5); |
|
|
|
|
limit = limit || (offset ? 20 : (prerendered || 5)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $q.when({ |
|
|
|
|
count: historyStorage.count, |
|
|
|
|
history: resultPending.concat(historyStorage.history.slice(offset, offset + limit)), |
|
|
|
@ -962,12 +963,11 @@ angular.module('myApp.services', [])
@@ -962,12 +963,11 @@ angular.module('myApp.services', [])
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!backLimit && !limit) { |
|
|
|
|
limit = 20; |
|
|
|
|
limit = prerendered || 20; |
|
|
|
|
} |
|
|
|
|
if (offsetNotFound) { |
|
|
|
|
offset = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (backLimit || unreadSkip || maxID && historyStorage.history.indexOf(maxID) == -1) { |
|
|
|
|
if (backLimit) { |
|
|
|
|
offset = -backLimit; |
|
|
|
@ -1203,6 +1203,7 @@ angular.module('myApp.services', [])
@@ -1203,6 +1203,7 @@ angular.module('myApp.services', [])
|
|
|
|
|
// console.log('done read history', peerID);
|
|
|
|
|
foundDialog[0].unread_count = 0; |
|
|
|
|
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: 0}); |
|
|
|
|
$rootScope.$broadcast('messages_read'); |
|
|
|
|
} |
|
|
|
|
})['finally'](function () { |
|
|
|
|
delete historyStorage.readPromise; |
|
|
|
@ -1312,6 +1313,7 @@ angular.module('myApp.services', [])
@@ -1312,6 +1313,7 @@ angular.module('myApp.services', [])
|
|
|
|
|
delete historyMessage.error; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$rootScope.$broadcast('messages_pending'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
message.send = function () { |
|
|
|
@ -1436,6 +1438,7 @@ angular.module('myApp.services', [])
@@ -1436,6 +1438,7 @@ angular.module('myApp.services', [])
|
|
|
|
|
delete historyMessage.error; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$rootScope.$broadcast('messages_pending'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
message.send = function () { |
|
|
|
@ -1577,6 +1580,7 @@ angular.module('myApp.services', [])
@@ -1577,6 +1580,7 @@ angular.module('myApp.services', [])
|
|
|
|
|
delete historyMessage.error; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$rootScope.$broadcast('messages_pending'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
message.send = function () { |
|
|
|
@ -1715,6 +1719,8 @@ angular.module('myApp.services', [])
@@ -1715,6 +1719,8 @@ angular.module('myApp.services', [])
|
|
|
|
|
delete historyMessage.error; |
|
|
|
|
delete historyMessage.random_id; |
|
|
|
|
delete historyMessage.send; |
|
|
|
|
|
|
|
|
|
$rootScope.$broadcast('messages_pending'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
delete messagesForHistory[tempID]; |
|
|
|
@ -1832,12 +1838,13 @@ angular.module('myApp.services', [])
@@ -1832,12 +1838,13 @@ angular.module('myApp.services', [])
|
|
|
|
|
|
|
|
|
|
function regroupWrappedHistory (history, limit) { |
|
|
|
|
if (!history || !history.length) { |
|
|
|
|
return; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
var start = 0, |
|
|
|
|
len = history.length, |
|
|
|
|
end = len, |
|
|
|
|
i, curDay, prevDay, curMessage, prevMessage; |
|
|
|
|
i, curDay, prevDay, curMessage, prevMessage, curGrouped, prevGrouped, |
|
|
|
|
wasUpdated = false; |
|
|
|
|
|
|
|
|
|
if (limit > 0) { |
|
|
|
|
end = Math.min(limit, len); |
|
|
|
@ -1849,10 +1856,19 @@ angular.module('myApp.services', [])
@@ -1849,10 +1856,19 @@ angular.module('myApp.services', [])
|
|
|
|
|
curMessage = history[i]; |
|
|
|
|
curDay = Math.floor((curMessage.date + midnightOffset) / 86400); |
|
|
|
|
|
|
|
|
|
prevGrouped = prevMessage && prevMessage.grouped; |
|
|
|
|
curGrouped = curMessage.grouped; |
|
|
|
|
|
|
|
|
|
if (curDay === prevDay) { |
|
|
|
|
delete curMessage.needDate; |
|
|
|
|
if (curMessage.needDate) { |
|
|
|
|
delete curMessage.needDate; |
|
|
|
|
wasUpdated = true; |
|
|
|
|
} |
|
|
|
|
} else if (!i || prevMessage) { |
|
|
|
|
curMessage.needDate = true; |
|
|
|
|
if (!curMessage.needDate) { |
|
|
|
|
curMessage.needDate = true; |
|
|
|
|
wasUpdated = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (prevMessage && |
|
|
|
@ -1883,9 +1899,17 @@ angular.module('myApp.services', [])
@@ -1883,9 +1899,17 @@ angular.module('myApp.services', [])
|
|
|
|
|
prevMessage.grouped += ' im_grouped_fwd_end'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!wasUpdated && prevGrouped != (prevMessage && prevMessage.grouped)) { |
|
|
|
|
wasUpdated = true; |
|
|
|
|
} |
|
|
|
|
prevMessage = curMessage; |
|
|
|
|
prevDay = curDay; |
|
|
|
|
} |
|
|
|
|
if (!wasUpdated && curGrouped != (prevMessage && prevMessage.grouped)) { |
|
|
|
|
wasUpdated = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return wasUpdated; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getDialogByPeerID (peerID) { |
|
|
|
@ -2085,7 +2109,8 @@ angular.module('myApp.services', [])
@@ -2085,7 +2109,8 @@ angular.module('myApp.services', [])
|
|
|
|
|
|
|
|
|
|
case 'updateReadMessages': |
|
|
|
|
var dialogsUpdated = {}, |
|
|
|
|
messageID, message, i, peerID, foundDialog, dialog; |
|
|
|
|
messageID, message, i, peerID, foundDialog, dialog, |
|
|
|
|
foundAffected = false; |
|
|
|
|
for (i = 0; i < update.messages.length; i++) { |
|
|
|
|
messageID = update.messages[i]; |
|
|
|
|
message = messagesStorage[messageID]; |
|
|
|
@ -2094,6 +2119,9 @@ angular.module('myApp.services', [])
@@ -2094,6 +2119,9 @@ angular.module('myApp.services', [])
|
|
|
|
|
message.unread = false; |
|
|
|
|
if (messagesForHistory[messageID]) { |
|
|
|
|
messagesForHistory[messageID].unread = false; |
|
|
|
|
if (!foundAffected) { |
|
|
|
|
foundAffected = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (messagesForDialogs[messageID]) { |
|
|
|
|
messagesForDialogs[messageID].unread = false; |
|
|
|
@ -2116,6 +2144,9 @@ angular.module('myApp.services', [])
@@ -2116,6 +2144,9 @@ angular.module('myApp.services', [])
|
|
|
|
|
angular.forEach(dialogsUpdated, function(count, peerID) { |
|
|
|
|
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: count}); |
|
|
|
|
}); |
|
|
|
|
if (foundAffected) { |
|
|
|
|
$rootScope.$broadcast('messages_read'); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'updateDeleteMessages': |
|
|
|
@ -2533,7 +2564,6 @@ angular.module('myApp.services', [])
@@ -2533,7 +2564,6 @@ angular.module('myApp.services', [])
|
|
|
|
|
full.width = fullWidth; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// console.log(222, video.w, video.h, full.width, full.height);
|
|
|
|
|
|
|
|
|
|
video.full = full; |
|
|
|
|
video.fullThumb = angular.copy(video.thumb); |
|
|
|
@ -3565,7 +3595,7 @@ angular.module('myApp.services', [])
@@ -3565,7 +3595,7 @@ angular.module('myApp.services', [])
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function notify (data) { |
|
|
|
|
console.log('notify', $rootScope.idle.isIDLE, notificationsUiSupport); |
|
|
|
|
// console.log('notify', $rootScope.idle.isIDLE, notificationsUiSupport);
|
|
|
|
|
|
|
|
|
|
// FFOS Notification blob src bug workaround
|
|
|
|
|
if (Config.Navigator.ffos) { |
|
|
|
|