Fix reactions order

This commit is contained in:
Eduard Kuzmenko 2022-09-26 11:54:18 +04:00
parent 13d9e952ba
commit 5d0c7f81fe
2 changed files with 14 additions and 13 deletions

View File

@ -124,11 +124,11 @@ export default class ReactionsElement extends HTMLElement {
// }) // })
) : []; ) : [];
if(this.message.peerId.isUser()) { // if(this.message.peerId.isUser()) {
counts.sort((a, b) => (b.count - a.count) || ((b.chosen_order ?? 0) - (a.chosen_order ?? 0))); // counts.sort((a, b) => (b.count - a.count) || ((b.chosen_order ?? 0) - (a.chosen_order ?? 0)));
} else { // } else {
counts.sort((a, b) => (b.count - a.count) || ((a.chosen_order ?? 0) - (b.chosen_order ?? 0))); counts.sort((a, b) => (b.count - a.count) || ((a.chosen_order ?? 0) - (b.chosen_order ?? 0)));
} // }
forEachReverse(this.sorted, (reactionElement, idx, arr) => { forEachReverse(this.sorted, (reactionElement, idx, arr) => {
const reaction = reactionElement.reactionCount.reaction; const reaction = reactionElement.reactionCount.reaction;

View File

@ -351,6 +351,7 @@ class ApiUpdatesManager {
channelState.syncPending = null; channelState.syncPending = null;
} }
const log = this.debug ? this.log.bindPrefix('getChannelDifference-' + channelId) : undefined;
// this.log.trace('Get channel diff', appChatsManager.getChat(channelId), channelState.pts); // this.log.trace('Get channel diff', appChatsManager.getChat(channelId), channelState.pts);
const promise = this.apiManager.invokeApi('updates.getChannelDifference', { const promise = this.apiManager.invokeApi('updates.getChannelDifference', {
channel: this.appChatsManager.getChannelInput(channelId), channel: this.appChatsManager.getChannelInput(channelId),
@ -358,16 +359,16 @@ class ApiUpdatesManager {
pts: channelState.pts, pts: channelState.pts,
limit: 30 limit: 30
}, {timeout: 0x7fffffff}).then((differenceResult) => { }, {timeout: 0x7fffffff}).then((differenceResult) => {
this.debug && this.log.debug('Get channel diff result', differenceResult) log?.debug('diff result', differenceResult)
channelState.pts = 'pts' in differenceResult ? differenceResult.pts : undefined; channelState.pts = 'pts' in differenceResult ? differenceResult.pts : undefined;
if(differenceResult._ === 'updates.channelDifferenceEmpty') { if(differenceResult._ === 'updates.channelDifferenceEmpty') {
this.debug && this.log.debug('apply channel empty diff', differenceResult); // log?.debug('apply channel empty diff', differenceResult);
return; return;
} }
if(differenceResult._ === 'updates.channelDifferenceTooLong') { if(differenceResult._ === 'updates.channelDifferenceTooLong') {
this.debug && this.log.debug('channel diff too long', differenceResult); // log?.debug('channel diff too long', differenceResult);
delete this.channelStates[channelId]; delete this.channelStates[channelId];
this.saveUpdate({_: 'updateChannelReload', channel_id: channelId}); this.saveUpdate({_: 'updateChannelReload', channel_id: channelId});
@ -378,12 +379,12 @@ class ApiUpdatesManager {
this.appChatsManager.saveApiChats(differenceResult.chats); this.appChatsManager.saveApiChats(differenceResult.chats);
// Should be first because of updateMessageID // Should be first because of updateMessageID
this.debug && this.log.debug('applying', differenceResult.other_updates.length, 'channel other updates'); log?.debug('applying', differenceResult.other_updates.length, 'channel other updates');
differenceResult.other_updates.forEach((update) => { differenceResult.other_updates.forEach((update) => {
this.saveUpdate(update); this.saveUpdate(update);
}); });
this.debug && this.log.debug('applying', differenceResult.new_messages.length, 'channel new messages'); log?.debug('applying', differenceResult.new_messages.length, 'channel new messages');
differenceResult.new_messages.forEach((apiMessage) => { differenceResult.new_messages.forEach((apiMessage) => {
this.saveUpdate({ this.saveUpdate({
_: 'updateNewChannelMessage', _: 'updateNewChannelMessage',
@ -393,13 +394,13 @@ class ApiUpdatesManager {
}); });
}); });
this.debug && this.log.debug('apply channel diff', channelState.pts); log?.debug('apply channel diff', channelState.pts);
if(differenceResult._ === 'updates.channelDifference' && if(differenceResult._ === 'updates.channelDifference' &&
!differenceResult.pFlags['final']) { !differenceResult.pFlags.final) {
return this.getChannelDifference(channelId); return this.getChannelDifference(channelId);
} else { } else {
this.debug && this.log.debug('finished channel get diff'); log?.debug('finished channel get diff');
} }
}); });