Skip to content

Commit

Permalink
Fix button handlers, re-registration, missing loadedProjectInfo and h…
Browse files Browse the repository at this point in the history
…ighlight hash
  • Loading branch information
tupui committed Sep 10, 2024
1 parent 5dc8193 commit 43ba04e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
35 changes: 18 additions & 17 deletions dapp/src/components/SetProject.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
});
}
});
</script>
8 changes: 4 additions & 4 deletions dapp/src/service/ProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | void> {
const projectId = loadedProjectId();
Expand Down Expand Up @@ -59,8 +59,9 @@ async function registerProject(
domain_contract_id: string,
): Promise<boolean> {
const projectId = loadedProjectId();
const projectInfo = loadedProjectInfo();

if (!projectId) {
if (!projectId || !projectInfo) {
alert("No project defined");
return false;
}
Expand All @@ -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,
Expand Down

0 comments on commit 43ba04e

Please sign in to comment.