Skip to content
This repository was archived by the owner on Aug 1, 2022. It is now read-only.

Commit ed040ca

Browse files
committed
simplify reactive declaration of patch fetching
Signed-off-by: Thomas Scholtes <[email protected]>
1 parent ee54c6f commit ed040ca

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

ui/App/ProjectScreen/Patch.svelte

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
export let view: "commits" | "discussion";
3232
export let patchCount: number;
3333
34-
let previousProject = project;
35-
let previousId = id;
36-
let previousPeerId = peerId;
37-
3834
type PatchStatus =
3935
| { type: "loading" }
4036
| { type: "notReplicated" }
@@ -46,27 +42,17 @@
4642
4743
let patchStatus: PatchStatus = { type: "loading" };
4844
45+
$: projectUrn = project.urn;
4946
$: {
50-
// Show loading indicator if we wanna show a different patch.
51-
if (
52-
project.urn !== previousProject.urn ||
53-
previousId !== id ||
54-
previousPeerId !== peerId
55-
) {
56-
patchStatus = { type: "loading" };
57-
previousProject = project;
58-
previousId = id;
59-
previousPeerId = peerId;
60-
}
61-
fetch(project, peerId, id);
47+
projectUrn;
48+
id;
49+
peerId;
50+
patchStatus = { type: "loading" };
51+
fetch();
6252
}
6353
6454
const fetchExecutor = mutexExecutor.create();
65-
async function fetch(
66-
project: Project,
67-
peerId: string,
68-
id: string
69-
): Promise<void> {
55+
async function fetch(): Promise<void> {
7056
try {
7157
const result = await fetchExecutor.run(async () => {
7258
return await patch.getDetails(project, peerId, id);
@@ -90,7 +76,7 @@
9076
function watchPatchUpdates(): () => void {
9177
return localPeer.projectEvents.onValue(event => {
9278
if (event.urn.startsWith(project.urn)) {
93-
fetch(project, peerId, id);
79+
fetch();
9480
}
9581
});
9682
}

0 commit comments

Comments
 (0)