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

30
app/js/services.js

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

Loading…
Cancel
Save