From 43ba04e5aea788754321cfaf6a16dfc000bc02c9 Mon Sep 17 00:00:00 2001 From: Tupui <23188539+tupui@users.noreply.github.com> Date: Tue, 10 Sep 2024 01:16:57 +0300 Subject: [PATCH] Fix button handlers, re-registration, missing loadedProjectInfo and highlight hash --- dapp/src/components/SetProject.astro | 35 ++++++++++++++-------------- dapp/src/service/ProjectService.ts | 8 +++---- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/dapp/src/components/SetProject.astro b/dapp/src/components/SetProject.astro index dd561a4..fb4c77b 100644 --- a/dapp/src/components/SetProject.astro +++ b/dapp/src/components/SetProject.astro @@ -56,24 +56,25 @@ const TANSU_CONTRACT_ID = import.meta.env.PUBLIC_TANSU_CONTRACT_ID; "[data-set-project]", ) as HTMLButtonElement; - button.addEventListener("click", async () => { - button.disabled = true; - try { - setProjectId(project_name.value); - const project = await getProject(); - if (project && project.name && project.config && project.maintainers) { - setProject(project); - const { username, repoName } = getAuthorRepo(project.config.url); - if (username && repoName) { - setProjectRepoInfo(username, repoName); + if (button) { + button.addEventListener("click", async () => { + try { + setProjectId(project_name.value); + const project = await getProject(); + if (project && project.name && project.config && project.maintainers) { + setProject(project); + const { username, repoName } = getAuthorRepo(project.config.url); + if (username && repoName) { + setProjectRepoInfo(username, repoName); + } + navigate("/commit"); + } else { + navigate("/register") } - navigate("/commit"); - } else { - navigate("/register") + } catch (e) { + console.error(e); } - } catch (e) { - console.error(e); - } - }); + }); + } }); diff --git a/dapp/src/service/ProjectService.ts b/dapp/src/service/ProjectService.ts index 37557c7..ecc8ba9 100644 --- a/dapp/src/service/ProjectService.ts +++ b/dapp/src/service/ProjectService.ts @@ -2,7 +2,7 @@ import { kit, loadedPublicKey } from "../components/stellar-wallets-kit"; import Versioning from "../contracts/soroban_versioning"; import type { Project } from "soroban_versioning"; -import { loadedProjectId } from "./StateService"; +import {loadedProjectId, loadedProjectInfo} from "./StateService"; async function getProjectHash(): Promise { const projectId = loadedProjectId(); @@ -59,8 +59,9 @@ async function registerProject( domain_contract_id: string, ): Promise { const projectId = loadedProjectId(); + const projectInfo = loadedProjectInfo(); - if (!projectId) { + if (!projectId || !projectInfo) { alert("No project defined"); return false; } @@ -76,8 +77,7 @@ async function registerProject( const maintainers_ = maintainers.split(","); const tx = await Versioning.register({ - // @ts-ignore - name: projectState.project_name, + name: projectInfo.name, maintainer: publicKey, maintainers: maintainers_, url: config_url,