Fix displaying dates in cached inner chat
This commit is contained in:
parent
0b3574ff9d
commit
941d0840b5
@ -2659,6 +2659,10 @@ export default class ChatBubbles {
|
|||||||
const afterSetPromise = Promise.all([setPeerPromise, getHeavyAnimationPromise()]);
|
const afterSetPromise = Promise.all([setPeerPromise, getHeavyAnimationPromise()]);
|
||||||
afterSetPromise.then(() => { // check whether list isn't full
|
afterSetPromise.then(() => { // check whether list isn't full
|
||||||
scrollable.checkForTriggers();
|
scrollable.checkForTriggers();
|
||||||
|
|
||||||
|
if(cached) {
|
||||||
|
this.onRenderScrollSet();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.chat.dispatchEvent('setPeer', lastMsgId, !isJump);
|
this.chat.dispatchEvent('setPeer', lastMsgId, !isJump);
|
||||||
@ -4063,18 +4067,20 @@ export default class ChatBubbles {
|
|||||||
} */
|
} */
|
||||||
|
|
||||||
let scrollSaver: ScrollSaver, hadScroll: boolean/* , viewportSlice: ReturnType<ChatBubbles['getViewportSlice']> */;
|
let scrollSaver: ScrollSaver, hadScroll: boolean/* , viewportSlice: ReturnType<ChatBubbles['getViewportSlice']> */;
|
||||||
this.messagesQueueOnRender = () => {
|
if(this.chatInner.parentElement) {
|
||||||
scrollSaver = new ScrollSaver(this.scrollable, reverse);
|
this.messagesQueueOnRender = () => {
|
||||||
|
scrollSaver = new ScrollSaver(this.scrollable, reverse);
|
||||||
if(this.getRenderedLength() && !this.chat.setPeerPromise) {
|
|
||||||
const viewportSlice = this.getViewportSlice();
|
if(this.getRenderedLength() && !this.chat.setPeerPromise) {
|
||||||
this.deleteViewportSlice(viewportSlice, true);
|
const viewportSlice = this.getViewportSlice();
|
||||||
}
|
this.deleteViewportSlice(viewportSlice, true);
|
||||||
|
}
|
||||||
scrollSaver.save();
|
|
||||||
const saved = scrollSaver.getSaved();
|
scrollSaver.save();
|
||||||
hadScroll = saved.scrollHeight !== saved.clientHeight;
|
const saved = scrollSaver.getSaved();
|
||||||
};
|
hadScroll = saved.scrollHeight !== saved.clientHeight;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if(this.needReflowScroll) {
|
if(this.needReflowScroll) {
|
||||||
reflowScrollableElement(this.scrollable.container);
|
reflowScrollableElement(this.scrollable.container);
|
||||||
@ -4122,12 +4128,26 @@ export default class ChatBubbles {
|
|||||||
|
|
||||||
if(scrollSaver) {
|
if(scrollSaver) {
|
||||||
scrollSaver.restore(history.length === 1 && !reverse ? false : true);
|
scrollSaver.restore(history.length === 1 && !reverse ? false : true);
|
||||||
|
this.onRenderScrollSet(scrollSaver.getSaved());
|
||||||
|
}
|
||||||
|
|
||||||
const className = 'has-sticky-dates';
|
return true;
|
||||||
const state = scrollSaver.getSaved();
|
}
|
||||||
|
|
||||||
|
private onRenderScrollSet(state?: {scrollHeight: number, clientHeight: number}) {
|
||||||
|
const className = 'has-sticky-dates';
|
||||||
|
if(!this.bubblesContainer.classList.contains(className)) {
|
||||||
const isLoading = !this.preloader.detached;
|
const isLoading = !this.preloader.detached;
|
||||||
const hasScroll = state.scrollHeight !== state.clientHeight;
|
|
||||||
if((hasScroll || isLoading) && !this.bubblesContainer.classList.contains(className)) {
|
if(isLoading ||
|
||||||
|
(
|
||||||
|
state ??= {
|
||||||
|
scrollHeight: this.scrollable.scrollHeight,
|
||||||
|
clientHeight: this.scrollable.container.clientHeight
|
||||||
|
},
|
||||||
|
state.scrollHeight !== state.clientHeight
|
||||||
|
)
|
||||||
|
) {
|
||||||
/* for(const timestamp in this.dateMessages) {
|
/* for(const timestamp in this.dateMessages) {
|
||||||
const dateMessage = this.dateMessages[timestamp];
|
const dateMessage = this.dateMessages[timestamp];
|
||||||
dateMessage.div.classList.add('is-sticky');
|
dateMessage.div.classList.add('is-sticky');
|
||||||
@ -4144,12 +4164,12 @@ export default class ChatBubbles {
|
|||||||
} else {
|
} else {
|
||||||
setTimeout(callback, 600);
|
setTimeout(callback, 600);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.willScrollOnLoad = undefined;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
this.willScrollOnLoad = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
onDatePick = (timestamp: number) => {
|
onDatePick = (timestamp: number) => {
|
||||||
|
@ -5568,7 +5568,7 @@ export class AppMessagesManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const chat: Chat.chat | Chat.channel = appChatsManager.getChat(message.peerId.toChatId());
|
const chat: Chat.chat | Chat.channel = appChatsManager.getChat(message.peerId.toChatId());
|
||||||
return chat.participants_count < rootScope.appConfig.chat_read_mark_size_threshold &&
|
return chat.participants_count <= rootScope.appConfig.chat_read_mark_size_threshold &&
|
||||||
(tsNow(true) - message.date) < rootScope.appConfig.chat_read_mark_expire_period;
|
(tsNow(true) - message.date) < rootScope.appConfig.chat_read_mark_expire_period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user