diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index 19e0e76e..59173ea6 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -2403,33 +2403,8 @@ export default class ChatBubbles { public requestHistory(maxId: number, loadCount: number, backLimit: number) { //const middleware = this.getMiddleware(); - if(this.chat.type === 'chat') { + if(this.chat.type === 'chat' || this.chat.type === 'discussion') { return this.appMessagesManager.getHistory(this.peerId, maxId, loadCount, backLimit, this.chat.threadId); - } else if(this.chat.type === 'discussion') { - const result = this.appMessagesManager.getHistory(this.peerId, maxId, loadCount, backLimit, this.chat.threadId); - const checkForStart = (historyResult: HistoryResult) => { - const topLoadCount = loadCount; - const isTopEnd = historyResult.offsetIdOffset >= (historyResult.count - topLoadCount); - this.log('discussion got history', loadCount, backLimit, historyResult, isTopEnd); - - // * inject discussion start - if(isTopEnd) { - const serviceStartMessageId = this.appMessagesManager.threadsServiceMessagesIdsStorage[this.peerId + '_' + this.chat.threadId]; - if(serviceStartMessageId) historyResult.history.push(serviceStartMessageId); - historyResult.history.push(this.chat.threadId); - this.scrolledAll = true; - } - }; - - if(result instanceof Promise) { - return result.then(result => { - checkForStart(result); - return result; - }); - } - - checkForStart(result); - return result; } else if(this.chat.type === 'pinned') { const promise = this.appMessagesManager.getSearch(this.peerId, '', {_: 'inputMessagesFilterPinned'}, maxId, loadCount, 0, backLimit) .then(value => ({history: value.history.map(m => m.mid)})); @@ -2539,6 +2514,20 @@ export default class ChatBubbles { ////console.timeEnd('render history total'); return Promise.reject(); } + + if(this.chat.type === 'discussion') { + const topLoadCount = loadCount; + const isTopEnd = result.offsetIdOffset >= (result.count - topLoadCount); + this.log('discussion got history', loadCount, backLimit, result, isTopEnd); + + // * inject discussion start + if(isTopEnd) { + const serviceStartMessageId = this.appMessagesManager.threadsServiceMessagesIdsStorage[this.peerId + '_' + this.chat.threadId]; + if(serviceStartMessageId) result.history.push(serviceStartMessageId); + result.history.push(this.chat.threadId); + this.scrolledAll = true; + } + } ////console.timeEnd('render history total'); diff --git a/src/scss/partials/_chatPinned.scss b/src/scss/partials/_chatPinned.scss index cc6b8074..04f1e149 100644 --- a/src/scss/partials/_chatPinned.scss +++ b/src/scss/partials/_chatPinned.scss @@ -393,6 +393,12 @@ display: none; } } + + .chat.type-discussion & { + .pinned-container-close { + display: none !important; + } + } } .pinned-audio {