From 831e85894b0c080d2e60afce41ccf1235aa95ce9 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Tue, 18 Feb 2025 17:18:16 +0100 Subject: [PATCH] fix: revert commitService.find to plain `invoke` incl invocation in EditMode.svelte --- apps/desktop/src/components/EditMode.svelte | 210 +++++++++--------- .../src/lib/commits/commitService.svelte.ts | 29 +-- apps/desktop/src/routes/+layout.svelte | 2 +- 3 files changed, 111 insertions(+), 130 deletions(-) diff --git a/apps/desktop/src/components/EditMode.svelte b/apps/desktop/src/components/EditMode.svelte index 4cc9a94d96..f4494b57e4 100644 --- a/apps/desktop/src/components/EditMode.svelte +++ b/apps/desktop/src/components/EditMode.svelte @@ -1,7 +1,7 @@ - - {#snippet children(commit)} -
-

- You are editing commit - {editModeMetadata.commitOid.slice(0, 7)} - - - Edit Mode lets you modify an existing commit in isolation or resolve conflicts. Any - changes made, including new files, will be added to the selected commit. - -

- -
-
-

- {commit?.descriptionTitle || 'Undefined commit'} -

- - {#if commit} -
- {#if authorImgUrl && commit.author.email} - - - {/if} - {editModeMetadata.commitOid.slice(0, 7)} - - {commit.author.name} -
+
+

+ You are editing commit + {editModeMetadata.commitOid.slice(0, 7)} + + + Edit Mode lets you modify an existing commit in isolation or resolve conflicts. Any changes + made, including new files, will be added to the selected commit. + +

+ +
+
+

+ {commit?.descriptionTitle || 'Undefined commit'} +

+ + {#if commit} +
+ {#if authorImgUrl && commit.author.email} + + {/if} - -
+ {editModeMetadata.commitOid.slice(0, 7)} + + {commit.author.name}
+ {/if} -
-
-

Commit files

- {files.length} -
- { - if (e.target instanceof HTMLElement) { - isCommitListScrolled = e.target.scrollTop > 0; - } - }} - > - {#each files as file (file.path)} -
- manuallyResolvedFiles.add(file.path) - : undefined} - conflictHint={file.conflictHint} - onclick={(e) => { - contextMenu?.open(e, { files: [file] }); - }} - oncontextmenu={(e) => { - contextMenu?.open(e, { files: [file] }); - }} - /> -
- {/each} -
-
-
+
+
- - -

- Please don't make any commits while in edit mode. -
- To exit edit mode, use the provided actions. -

- -
- - {#if conflictedFiles.length > 0} - - {/if} - +
+
+

Commit files

+ {files.length}
+ { + if (e.target instanceof HTMLElement) { + isCommitListScrolled = e.target.scrollTop > 0; + } + }} + > + {#each files as file (file.path)} +
+ manuallyResolvedFiles.add(file.path) + : undefined} + conflictHint={file.conflictHint} + onclick={(e) => { + contextMenu?.open(e, { files: [file] }); + }} + oncontextmenu={(e) => { + contextMenu?.open(e, { files: [file] }); + }} + /> +
+ {/each} +
- {/snippet} - +
+ + + +

+ Please don't make any commits while in edit mode. +
+ To exit edit mode, use the provided actions. +

+ +
+ + {#if conflictedFiles.length > 0} + + {/if} + +
+
; - - constructor(state: ClientState) { - this.api = injectEndpoints(state.backendApi); - } - - find(projectId: string, commitOid: string) { - const result = $derived(this.api.endpoints.find.useQuery({ projectId, commitOid })); - return result; + async find(projectId: string, commitOid: string) { + return plainToInstance(Commit, await invoke('find_commit', { projectId, commitOid })); } } - -function injectEndpoints(api: ClientState['backendApi']) { - return api.injectEndpoints({ - endpoints: (build) => ({ - find: build.query({ - query: ({ projectId, commitOid }) => ({ - command: 'find_commit', - params: { projectId, commitOid } - }), - transformResponse: (response: unknown) => plainToInstance(Commit, response), - providesTags: [ReduxTag.Commit] - }) - }) - }); -} diff --git a/apps/desktop/src/routes/+layout.svelte b/apps/desktop/src/routes/+layout.svelte index b378fbb707..8ae8ad536e 100644 --- a/apps/desktop/src/routes/+layout.svelte +++ b/apps/desktop/src/routes/+layout.svelte @@ -101,7 +101,7 @@ const desktopRouteService = new DesktopRoutesService(); const diffService = new DiffService(clientState); const shortcutService = new ShortcutService(data.tauri); - const commitService = new CommitService(clientState); + const commitService = new CommitService(); shortcutService.listen();