desktop: Refresh lists once after context menu edits

Each write already refreshes what it changed, so the menus' own refresh
loaded the list a second time.
This commit is contained in:
Rūdolfs Ošiņš
2026-11-20 19:32:17 +01:00
parent b1c3e2c639
commit cc65aea3be
5 changed files with 4 additions and 20 deletions
@@ -26,7 +26,6 @@
repo: RepoInfo;
config: Config;
labelSuggestions: string[];
onchange: () => Promise<void>;
onclose: () => void;
}
@@ -38,7 +37,6 @@
repo,
config,
labelSuggestions,
onchange,
onclose,
}: Props = $props();
@@ -57,7 +55,7 @@
),
);
const enqueue = serialEdits("Editing issue failed", () => onchange());
const enqueue = serialEdits("Editing issue failed");
function edit(action: Action) {
const args = {
@@ -75,7 +73,6 @@
cobId: issue.id,
opts: { announce: $nodeRunning && $announce },
};
const refresh = onchange;
show({
component: ConfirmDeleteCob,
props: {
@@ -84,7 +81,6 @@
icon: "issue",
confirm: async () => {
await invoke("delete_issue", args);
await refresh();
},
},
});
@@ -26,7 +26,6 @@
repo: RepoInfo;
config: Config;
labelSuggestions: string[];
onchange: () => Promise<void>;
onclose: () => void;
}
@@ -38,7 +37,6 @@
repo,
config,
labelSuggestions,
onchange,
onclose,
}: Props = $props();
@@ -58,7 +56,7 @@
),
);
const enqueue = serialEdits("Editing patch failed", () => onchange());
const enqueue = serialEdits("Editing patch failed");
function edit(action: Action) {
const args = {
@@ -80,7 +78,6 @@
cobId: patch.id,
opts: { announce: $nodeRunning && $announce },
};
const refresh = onchange;
show({
component: ConfirmDeleteCob,
props: {
@@ -89,7 +86,6 @@
icon: "patch",
confirm: async () => {
await invoke("delete_patch", args);
await refresh();
},
},
});
+2 -8
View File
@@ -1,22 +1,16 @@
// Runs edits one at a time in submission order and refreshes once the queue
// drains, so quick successive toggles neither race nor refresh per edit.
// Runs edits one at a time in submission order, so quick successive toggles
// don't race. Each write refreshes what it changed by itself.
export function serialEdits(
errorMessage: string,
refresh: () => Promise<void>,
): (run: () => Promise<unknown>) => void {
let queue: Promise<void> = Promise.resolve();
let pending = 0;
return run => {
pending += 1;
queue = queue.then(async () => {
try {
await run();
} catch (error) {
console.error(errorMessage, error);
} finally {
pending -= 1;
if (pending === 0) await refresh();
}
});
};
-1
View File
@@ -374,7 +374,6 @@
{repo}
config={sidebarData.config}
labelSuggestions={contextMenu.labelSuggestions}
onchange={refresh}
onclose={contextMenu.close} />
{/if}
</Layout>
-1
View File
@@ -402,7 +402,6 @@
{repo}
config={sidebarData.config}
labelSuggestions={contextMenu.labelSuggestions}
onchange={refresh}
onclose={contextMenu.close} />
{/if}
</Layout>