22 lines
761 B
TypeScript
22 lines
761 B
TypeScript
const pendingRenames = new Map<string, { attemptId: string; controller: AbortController }>();
|
|
|
|
export const cancelPendingRename = (topicId: string, attemptId?: string | null) => {
|
|
const pending = pendingRenames.get(topicId);
|
|
if (pending && pending.attemptId === attemptId) {
|
|
pending.controller.abort();
|
|
pendingRenames.delete(topicId);
|
|
}
|
|
};
|
|
|
|
export const completeRename = (topicId: string, attemptId: string) => {
|
|
if (pendingRenames.get(topicId)?.attemptId === attemptId) {
|
|
pendingRenames.delete(topicId);
|
|
}
|
|
};
|
|
|
|
export const addPendingRename = (topicId: string, attemptId: string) => {
|
|
const controller = new AbortController();
|
|
pendingRenames.set(topicId, { attemptId, controller });
|
|
return controller;
|
|
};
|