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" 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