From ffc006557f00837e6e8f0e172e22c94e76ff6d82 Mon Sep 17 00:00:00 2001 From: morethanwords Date: Wed, 24 Feb 2021 16:19:44 +0400 Subject: [PATCH] Temp commit 2 --- src/helpers/slicedArray.ts | 15 +++++++++++---- src/lib/appManagers/appMessagesManager.ts | 6 ++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/helpers/slicedArray.ts b/src/helpers/slicedArray.ts index 83e44c0a..9273e91f 100644 --- a/src/helpers/slicedArray.ts +++ b/src/helpers/slicedArray.ts @@ -110,13 +110,20 @@ export default class SlicedArray { for(let i = 0; i < this.slices.length; ++i) { let offset = 0; const slice = this.slices[i]; + if(slice.length < 2) { + continue; + } + for(; offset < slice.length; offset++) { - if(maxId > slice[offset]) { - if(!offset) { // because can't find 3 in [[5,4], [2,1]] + if(maxId >= slice[offset]) { + /* if(!offset) { // because can't find 3 in [[5,4], [2,1]] return undefined; - } + } */ - return {slice, offset: offset - 1}; + return { + slice, + offset: maxId === slice[offset] ? offset : offset - 1 + }; } } } diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index ef33aa04..835391e2 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -4664,7 +4664,9 @@ export class AppMessagesManager { }); const mids = historyResult.messages.map((message) => (message as MyMessage).mid); - /* if(maxId && !mids.includes(maxId)) { + // * add bound manually. + // * offset_id will be inclusive only if there is 'add_offset' <= -1 (-1 - will only include the 'offset_id') + if(maxId && !mids.includes(maxId)) { let i = 0; for(const length = mids.length; i < length; ++i) { if(maxId > mids[i]) { @@ -4673,7 +4675,7 @@ export class AppMessagesManager { } mids.splice(i, 0, maxId); - } */ + } historyStorage.history.insertSlice(mids);