Browse Source

Fix saving sent messages

master
Eduard Kuzmenko 4 years ago
parent
commit
7abe2dc4eb
  1. 16
      src/lib/appManagers/appMessagesManager.ts

16
src/lib/appManagers/appMessagesManager.ts

@ -3695,8 +3695,20 @@ export class AppMessagesManager {
return false; return false;
} }
const slice = historyStorage.history.insertSlice([message.mid]); // * catch situation with disconnect. if message's id is lower than we already have (in bottom end slice), will sort it
slice.setEnd(SliceEnd.Bottom); const firstSlice = historyStorage.history.first;
if(firstSlice.isEnd(SliceEnd.Bottom)) {
let i = 0;
for(const length = firstSlice.length; i < length; ++i) {
if(message.mid > firstSlice[i]) {
break;
}
}
firstSlice.splice(i, 0, message.mid);
} else {
historyStorage.history.unshift(message.mid);
}
if(historyStorage.count !== null) { if(historyStorage.count !== null) {
historyStorage.count++; historyStorage.count++;

Loading…
Cancel
Save