mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 10:19:08 +00:00
Ensure reactions are handled in order
This commit is contained in:
@@ -2470,7 +2470,7 @@ export async function startApp(): Promise<void> {
|
|||||||
timestamp,
|
timestamp,
|
||||||
};
|
};
|
||||||
|
|
||||||
drop(Reactions.onReaction(attributes));
|
await Reactions.onReaction(attributes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2971,7 +2971,7 @@ export async function startApp(): Promise<void> {
|
|||||||
receivedAtDate: data.receivedAtDate,
|
receivedAtDate: data.receivedAtDate,
|
||||||
timestamp,
|
timestamp,
|
||||||
};
|
};
|
||||||
drop(Reactions.onReaction(attributes));
|
await Reactions.onReaction(attributes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,6 @@ export async function onReaction(
|
|||||||
|
|
||||||
const logId = `Reactions.onReaction(timestamp=${reaction.timestamp};target=${reaction.targetTimestamp})`;
|
const logId = `Reactions.onReaction(timestamp=${reaction.timestamp};target=${reaction.targetTimestamp})`;
|
||||||
|
|
||||||
try {
|
|
||||||
const matchingMessage = await findMessageForReaction({
|
const matchingMessage = await findMessageForReaction({
|
||||||
targetTimestamp: reaction.targetTimestamp,
|
targetTimestamp: reaction.targetTimestamp,
|
||||||
targetAuthorAci: reaction.targetAuthorAci,
|
targetAuthorAci: reaction.targetAuthorAci,
|
||||||
@@ -259,12 +258,10 @@ export async function onReaction(
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// awaiting is safe since `onReaction` is never called from inside the queue
|
drop(
|
||||||
await matchingMessageConversation.queueJob(
|
matchingMessageConversation.queueJob('Reactions.onReaction', async () => {
|
||||||
'Reactions.onReaction',
|
|
||||||
async () => {
|
|
||||||
log.info(`${logId}: handling`);
|
log.info(`${logId}: handling`);
|
||||||
|
try {
|
||||||
// Message is fetched inside the conversation queue so we have the
|
// Message is fetched inside the conversation queue so we have the
|
||||||
// most recent data
|
// most recent data
|
||||||
const targetMessage = await findMessageForReaction({
|
const targetMessage = await findMessageForReaction({
|
||||||
@@ -302,12 +299,12 @@ export async function onReaction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
remove(reaction);
|
remove(reaction);
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
remove(reaction);
|
remove(reaction);
|
||||||
log.error(`${logId} error:`, Errors.toLogFormat(error));
|
log.error(`${logId} error:`, Errors.toLogFormat(error));
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handleReaction(
|
export async function handleReaction(
|
||||||
|
|||||||
Reference in New Issue
Block a user