Browse Source

Fix sending voice messages

Fix unneeded reading of bottom messages
master
Eduard Kuzmenko 2 years ago
parent
commit
ea195b380a
  1. 32
      src/components/audio.ts
  2. 31
      src/components/chat/bubbles.ts
  3. 4
      src/helpers/scrollSaver.ts

32
src/components/audio.ts

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

31
src/components/chat/bubbles.ts

@ -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,22 +2902,23 @@ 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));
if(dialog?.pFlags.unread_mark) { if(dialog?.pFlags.unread_mark) {

4
src/helpers/scrollSaver.ts

@ -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) {

Loading…
Cancel
Save