Browse Source

Minor improvements

master
Igor Zhukov 10 years ago
parent
commit
b2780a3f15
  1. 2
      app/js/controllers.js
  2. 30
      app/js/services.js

2
app/js/controllers.js

@ -1165,8 +1165,10 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.state.mayBeHasMore = true; $scope.state.mayBeHasMore = true;
console.log(dT(), 'start load history', $scope.curDialog);
getMessagesPromise.then(function (historyResult) { getMessagesPromise.then(function (historyResult) {
if (curJump != jump) return; if (curJump != jump) return;
console.log(dT(), 'history loaded', historyResult);
var fetchedLength = historyResult.history.length; var fetchedLength = historyResult.history.length;

30
app/js/services.js

@ -1833,7 +1833,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var peerID = pendingData[0], var peerID = pendingData[0],
tempID = pendingData[1], tempID = pendingData[1],
historyStorage = historiesStorage[peerID], historyStorage = historiesStorage[peerID],
i; pos = historyStorage.pending.indexOf(tempID);
ApiUpdatesManager.processUpdateMessage({ ApiUpdatesManager.processUpdateMessage({
_: 'updateShort', _: 'updateShort',
@ -1843,17 +1843,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
}); });
for (i = 0; i < historyStorage.pending.length; i++) { if (pos != -1) {
if (historyStorage.pending[i] == tempID) { historyStorage.pending.splice(pos, 1);
historyStorage.pending.splice(i, 1);
break;
}
} }
delete messagesForHistory[tempID]; delete messagesForHistory[tempID];
delete messagesStorage[tempID]; delete messagesStorage[tempID];
return true; return true;
} }
@ -1868,17 +1864,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var peerID = pendingData[0], var peerID = pendingData[0],
tempID = pendingData[1], tempID = pendingData[1],
historyStorage = historiesStorage[peerID], historyStorage = historiesStorage[peerID],
index = false, message,
message = false, historyMessage;
historyMessage = false,
i;
// console.log('pending', randomID, historyStorage.pending); // console.log('pending', randomID, historyStorage.pending);
for (i = 0; i < historyStorage.pending.length; i++) { var pos = historyStorage.pending.indexOf(tempID);
if (historyStorage.pending[i] == tempID) { if (pos != -1) {
historyStorage.pending.splice(i, 1); historyStorage.pending.splice(pos, 1);
break;
}
} }
if (message = messagesStorage[tempID]) { if (message = messagesStorage[tempID]) {
@ -2315,18 +2307,16 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
historyStorage = historiesStorage[peerID]; historyStorage = historiesStorage[peerID];
if (historyStorage !== undefined) { if (historyStorage !== undefined) {
var topMsgID = historiesStorage[peerID].history[0];
if (historiesStorage[peerID].history.indexOf(message.id) != -1) { if (historiesStorage[peerID].history.indexOf(message.id) != -1) {
return false; return false;
} }
else { var topMsgID = historiesStorage[peerID].history[0];
historyStorage.history.unshift(message.id); historyStorage.history.unshift(message.id);
if (message.id > 0 && message.id < topMsgID || true) { if (message.id > 0 && message.id < topMsgID) {
historyStorage.history.sort(function (a, b) { historyStorage.history.sort(function (a, b) {
return b - a; return b - a;
}); });
} }
}
} else { } else {
historyStorage = historiesStorage[peerID] = {count: null, history: [message.id], pending: []}; historyStorage = historiesStorage[peerID] = {count: null, history: [message.id], pending: []};
} }

Loading…
Cancel
Save