Fix sending voice messages

Fix unneeded reading of bottom messages
This commit is contained in:
Eduard Kuzmenko 2022-06-28 19:13:03 +02:00
parent 5ac206aea9
commit ea195b380a
3 changed files with 41 additions and 34 deletions

View File

@ -692,23 +692,29 @@ export default class AudioElement extends HTMLElement {
} }
disconnectedCallback() { disconnectedCallback() {
if(this.isConnected) { setTimeout(() => {
return; if(this.isConnected) {
} return;
}
if(this.onTypeDisconnect) {
this.onTypeDisconnect(); if(this.onTypeDisconnect) {
this.onTypeDisconnect = null; this.onTypeDisconnect();
} this.onTypeDisconnect = null;
}
if(this.readyPromise) {
this.readyPromise.reject(); if(this.readyPromise) {
} this.readyPromise.reject();
}
this.listenerSetter.removeAll();
this.listenerSetter = null; if(this.listenerSetter) {
this.listenerSetter.removeAll();
this.preloader = null; this.listenerSetter = null;
}
if(this.preloader) {
this.preloader = null;
}
}, 100);
} }
} }

View File

@ -323,7 +323,7 @@ export default class ChatBubbles {
const _items = this.bubbleGroups.itemsArr.slice(); const _items = this.bubbleGroups.itemsArr.slice();
indexOfAndSplice(_items, item); indexOfAndSplice(_items, item);
const foundItem = this.bubbleGroups.findGroupSiblingByItem(newItem, _items); const foundItem = this.bubbleGroups.findGroupSiblingByItem(newItem, _items);
if(group === foundItem?.group/* && false */) { if(group === foundItem?.group || (group === this.bubbleGroups.getLastGroup() && group.items.length === 1)/* && false */) {
log && log('item has correct position', item); log && log('item has correct position', item);
this.bubbleGroups.changeBubbleMid(bubble, mid); this.bubbleGroups.changeBubbleMid(bubble, mid);
return; return;
@ -2902,21 +2902,22 @@ export default class ChatBubbles {
this.chat.dispatchEvent('setPeer', lastMsgId, !isJump); this.chat.dispatchEvent('setPeer', lastMsgId, !isJump);
this.setFetchReactionsInterval(afterSetPromise); Promise.all([
this.setFetchHistoryInterval({ this.setFetchReactionsInterval(afterSetPromise),
afterSetPromise, this.setFetchHistoryInterval({
lastMsgId, afterSetPromise,
samePeer, lastMsgId,
savedPosition, samePeer,
topMessage savedPosition,
topMessage
}),
]).then(() => {
log('scrolledAllDown:', scrollable.loadedAll.bottom);
//if(!this.unreaded.length && dialog) { // lol
if(scrollable.loadedAll.bottom && topMessage && !this.unreaded.size) { // lol
this.onScrolledAllDown();
}
}); });
log('scrolledAllDown:', scrollable.loadedAll.bottom);
//if(!this.unreaded.length && dialog) { // lol
if(scrollable.loadedAll.bottom && topMessage && !this.unreaded.size) { // lol
this.onScrolledAllDown();
}
if(chatType === 'chat') { if(chatType === 'chat') {
const dialog = await m(this.managers.appMessagesManager.getDialogOnly(peerId)); const dialog = await m(this.managers.appMessagesManager.getDialogOnly(peerId));

View File

@ -85,7 +85,7 @@ export default class ScrollSaver {
public save() { public save() {
this.findAndSetElements(); this.findAndSetElements();
console.warn('scroll save', this.elements); // console.warn('scroll save', this.elements);
this._save(); this._save();
} }
@ -152,7 +152,7 @@ export default class ScrollSaver {
const diff = newRect.bottom - rect.bottom; const diff = newRect.bottom - rect.bottom;
this.setScrollTop(scrollTop + diff, useReflow); this.setScrollTop(scrollTop + diff, useReflow);
// if(diff) debugger; // if(diff) debugger;
console.warn('scroll restore', rect, diff, newRect); // console.warn('scroll restore', rect, diff, newRect);
} }
public _restore(useReflow?: boolean) { public _restore(useReflow?: boolean) {