Forwards: Fix message order jumps (#3673)
This commit is contained in:
parent
68ef919c66
commit
4a2b7eb7fd
@ -108,12 +108,10 @@ import { ensureProtocol } from '../../../util/ensureProtocol';
|
|||||||
import { updateTabState } from '../../reducers/tabs';
|
import { updateTabState } from '../../reducers/tabs';
|
||||||
import { getCurrentTabId } from '../../../util/establishMultitabRole';
|
import { getCurrentTabId } from '../../../util/establishMultitabRole';
|
||||||
import { deleteMessages } from '../apiUpdaters/messages';
|
import { deleteMessages } from '../apiUpdaters/messages';
|
||||||
import Deferred from '../../../util/Deferred';
|
|
||||||
|
|
||||||
const AUTOLOGIN_TOKEN_KEY = 'autologin_token';
|
const AUTOLOGIN_TOKEN_KEY = 'autologin_token';
|
||||||
|
|
||||||
const uploadProgressCallbacks = new Map<number, ApiOnProgress>();
|
const uploadProgressCallbacks = new Map<number, ApiOnProgress>();
|
||||||
let lastSendMessageDeferred = Deferred.resolved();
|
|
||||||
|
|
||||||
const runDebouncedForMarkRead = debounce((cb) => cb(), 500, false);
|
const runDebouncedForMarkRead = debounce((cb) => cb(), 500, false);
|
||||||
|
|
||||||
@ -804,8 +802,8 @@ addActionHandler('forwardMessages', (global, actions, payload): ActionReturnType
|
|||||||
const realMessages = messages.filter((m) => !isServiceNotificationMessage(m));
|
const realMessages = messages.filter((m) => !isServiceNotificationMessage(m));
|
||||||
if (realMessages.length) {
|
if (realMessages.length) {
|
||||||
(async () => {
|
(async () => {
|
||||||
await lastSendMessageDeferred.promise;
|
await rafPromise(); // Wait one frame for any previous `sendMessage` to be processed
|
||||||
await callApi('forwardMessages', {
|
callApi('forwardMessages', {
|
||||||
fromChat,
|
fromChat,
|
||||||
toChat,
|
toChat,
|
||||||
toThreadId,
|
toThreadId,
|
||||||
@ -1176,7 +1174,6 @@ async function sendMessage<T extends GlobalState>(global: T, params: {
|
|||||||
replyingToTopId?: number;
|
replyingToTopId?: number;
|
||||||
groupedId?: string;
|
groupedId?: string;
|
||||||
}) {
|
}) {
|
||||||
lastSendMessageDeferred = new Deferred();
|
|
||||||
let localId: number | undefined;
|
let localId: number | undefined;
|
||||||
const progressCallback = params.attachment ? (progress: number, messageLocalId: number) => {
|
const progressCallback = params.attachment ? (progress: number, messageLocalId: number) => {
|
||||||
if (!uploadProgressCallbacks.has(messageLocalId)) {
|
if (!uploadProgressCallbacks.has(messageLocalId)) {
|
||||||
@ -1221,8 +1218,6 @@ async function sendMessage<T extends GlobalState>(global: T, params: {
|
|||||||
if (progressCallback && localId) {
|
if (progressCallback && localId) {
|
||||||
uploadProgressCallbacks.delete(localId);
|
uploadProgressCallbacks.delete(localId);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastSendMessageDeferred.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addActionHandler('loadPinnedMessages', async (global, actions, payload): Promise<void> => {
|
addActionHandler('loadPinnedMessages', async (global, actions, payload): Promise<void> => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user