mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
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:
@@ -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();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -374,7 +374,6 @@
|
||||
{repo}
|
||||
config={sidebarData.config}
|
||||
labelSuggestions={contextMenu.labelSuggestions}
|
||||
onchange={refresh}
|
||||
onclose={contextMenu.close} />
|
||||
{/if}
|
||||
</Layout>
|
||||
|
||||
@@ -402,7 +402,6 @@
|
||||
{repo}
|
||||
config={sidebarData.config}
|
||||
labelSuggestions={contextMenu.labelSuggestions}
|
||||
onchange={refresh}
|
||||
onclose={contextMenu.close} />
|
||||
{/if}
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user