From 09b02feb783a437a1cd538602125c76b88a34107 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Tue, 10 Sep 2024 19:29:24 +0200 Subject: [PATCH] fix: wire up prService template fns correctly --- apps/desktop/src/lib/branch/BranchHeader.svelte | 2 +- apps/desktop/src/lib/gitHost/github/githubPrService.ts | 2 +- apps/desktop/src/lib/settings/GitHostForm.svelte | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/lib/branch/BranchHeader.svelte b/apps/desktop/src/lib/branch/BranchHeader.svelte index de95655720..3627eb97ba 100644 --- a/apps/desktop/src/lib/branch/BranchHeader.svelte +++ b/apps/desktop/src/lib/branch/BranchHeader.svelte @@ -91,7 +91,7 @@ const prTemplatePath = project.git_host.pullRequestTemplatePath; if (prTemplatePath) { - pullRequestTemplateBody = await $gitHost.getPrTemplateContent(prTemplatePath); + pullRequestTemplateBody = await $prService?.getPrTemplateContent(prTemplatePath); } if (pullRequestTemplateBody) { diff --git a/apps/desktop/src/lib/gitHost/github/githubPrService.ts b/apps/desktop/src/lib/gitHost/github/githubPrService.ts index 3f7d1a40cc..dae9c2f052 100644 --- a/apps/desktop/src/lib/gitHost/github/githubPrService.ts +++ b/apps/desktop/src/lib/gitHost/github/githubPrService.ts @@ -107,7 +107,7 @@ export class GitHubPrService implements GitHostPrService { const availableTemplates: string[] | undefined = await invoke( 'available_pull_request_templates', - { path: targetPath } + { rootPath: targetPath } ); return availableTemplates; diff --git a/apps/desktop/src/lib/settings/GitHostForm.svelte b/apps/desktop/src/lib/settings/GitHostForm.svelte index 1b38822394..59ef468150 100644 --- a/apps/desktop/src/lib/settings/GitHostForm.svelte +++ b/apps/desktop/src/lib/settings/GitHostForm.svelte @@ -2,6 +2,7 @@ import { Project, ProjectService } from '$lib/backend/projects'; import SectionCard from '$lib/components/SectionCard.svelte'; import { getGitHost } from '$lib/gitHost/interface/gitHost'; + import { createGitHostPrServiceStore } from '$lib/gitHost/interface/gitHostPrService'; import Select from '$lib/select/Select.svelte'; import SelectItem from '$lib/select/SelectItem.svelte'; import Section from '$lib/settings/Section.svelte'; @@ -12,6 +13,8 @@ const projectService = getContext(ProjectService); const project = getContext(Project); const gitHost = getGitHost(); + const prService = createGitHostPrServiceStore(undefined); + $effect(() => prService.set($gitHost?.prService())); let useTemplate = $state(!!project.git_host?.pullRequestTemplatePath); let selectedTemplate = $state(project.git_host?.pullRequestTemplatePath ?? ''); @@ -19,7 +22,7 @@ $effect(() => { if (!project.path) return; - $gitHost?.getAvailablePrTemplates(project.path).then((availableTemplates) => { + $prService?.getAvailablePrTemplates(project.path).then((availableTemplates) => { if (availableTemplates) { allAvailableTemplates = availableTemplates.map((availableTemplate) => { return {