From 8e03b6588ebefbe5279d68cd69871f3448740146 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 5 Dec 2024 18:41:41 +0100 Subject: [PATCH 1/2] backport svelte race condition --- ...{{pascal_case collection_name}}.svelte.hbs | 6 ++++-- ...{{pascal_case entry_type.name}}.svelte.hbs | 8 +++++--- ....svelte{{\302\241if}}{{\302\241each}}.hbs" | 7 ++++--- ...ntry_type.name}}.svelte{{\302\241if}}.hbs" | 8 +++++--- ...al_case entry_type.name}}Detail.svelte.hbs | 6 ++++-- ...renceable.name}}.svelte{{\302\241if}}.hbs" | 6 ++++-- ...renceable.name}}.svelte{{\302\241if}}.hbs" | 6 ++++-- .../svelte/web-app/ui/src/App.svelte.hbs | 19 +++++++++++++------ .../svelte/web-app/ui/src/contexts.ts.hbs | 8 +++++++- 9 files changed, 50 insertions(+), 24 deletions(-) diff --git a/templates/ui-frameworks/svelte/collection/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{pascal_case collection_name}}.svelte.hbs b/templates/ui-frameworks/svelte/collection/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{pascal_case collection_name}}.svelte.hbs index 56a099e95..75a44471e 100644 --- a/templates/ui-frameworks/svelte/collection/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{pascal_case collection_name}}.svelte.hbs +++ b/templates/ui-frameworks/svelte/collection/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{pascal_case collection_name}}.svelte.hbs @@ -10,11 +10,12 @@ import type { NewEntryAction, HolochainError, } from '@holochain/client'; -import { clientContext } from '../../contexts'; +import { type ClientContext, clientContext } from '../../contexts'; import {{pascal_case referenceable.name}}Detail from './{{pascal_case referenceable.name}}Detail.svelte'; import type { {{pascal_case coordinator_zome_manifest.name}}Signal } from './types'; -const client: AppClient = (getContext(clientContext) as any).getClient(); +let client: AppClient; +const appClientContext = getContext(clientContext); let hashes: Array<{{referenceable.hash_type}}> = []; let loading = false; @@ -31,6 +32,7 @@ onMount(async () => { throw new Error(`The author input is required for the {{pascal_case collection_name}} element`); } {{/if}} + client = await appClientContext.getClient(); await fetch{{pascal_case (plural referenceable.name)}}(); client.on('signal', signal => { if (signal.zome_name !== '{{coordinator_zome_manifest.name}}') return; diff --git a/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.svelte.hbs b/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.svelte.hbs index cd1c9eae6..a0c7a6edf 100644 --- a/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.svelte.hbs +++ b/templates/ui-frameworks/svelte/entry-type/ui/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/Create{{pascal_case entry_type.name}}.svelte.hbs @@ -1,7 +1,7 @@
diff --git a/templates/ui-frameworks/svelte/web-app/ui/src/contexts.ts.hbs b/templates/ui-frameworks/svelte/web-app/ui/src/contexts.ts.hbs index 9f41a2624..76cade143 100644 --- a/templates/ui-frameworks/svelte/web-app/ui/src/contexts.ts.hbs +++ b/templates/ui-frameworks/svelte/web-app/ui/src/contexts.ts.hbs @@ -1 +1,7 @@ -export const clientContext = 'AppClient'; \ No newline at end of file +import { type AppClient } from "@holochain/client"; + +export const clientContext = "AppClient"; + +export type ClientContext = { + getClient: () => Promise; +}; \ No newline at end of file From 11c3aaaa14a293f8eb81d0dd73703f832696c01c Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 5 Dec 2024 18:44:24 +0100 Subject: [PATCH 2/2] bump scaffolding version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47bbab13b..751744ea2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1867,7 +1867,7 @@ dependencies = [ [[package]] name = "holochain_scaffolding_cli" -version = "0.3000.10" +version = "0.3000.11" dependencies = [ "anyhow", "build-fs-tree", diff --git a/Cargo.toml b/Cargo.toml index b454d9004..32673d317 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "holochain_scaffolding_cli" -version = "0.3000.10" +version = "0.3000.11" description = "CLI to easily generate and modify holochain apps" license = "CAL-1.0" homepage = "https://developer.holochain.org"