From 5554a51c8fec033794aec9d38915e43d10ed45c7 Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Tue, 29 Aug 2023 13:34:28 -0700 Subject: [PATCH] fix(ui): remove unnecessary HoloLogin component, await holo client signals to trigger signup and resolve client setup --- ui/src/App.vue | 7 +------ ui/src/components/HoloLogin.vue | 31 ------------------------------- ui/src/utils/client.ts | 12 +++++++++++- 3 files changed, 12 insertions(+), 38 deletions(-) delete mode 100644 ui/src/components/HoloLogin.vue diff --git a/ui/src/App.vue b/ui/src/App.vue index f43260fc..3222e893 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -12,11 +12,7 @@ class="w-full flex justify-center items-center relative font-content cursor-default" > - - - - - +
import { computed, onMounted, provide, ref, toRaw, watch } from "vue"; import { IS_HOLO_HOSTED, setupHolo, setupHolochain } from "@/utils/client"; -import HoloLogin from "@/components/HoloLogin.vue"; import MainLayout from "@/layouts/MainLayout.vue"; import { PROFILES_CONFIG } from "@/utils/profiles"; import "@shoelace-style/shoelace/dist/components/spinner/spinner"; diff --git a/ui/src/components/HoloLogin.vue b/ui/src/components/HoloLogin.vue deleted file mode 100644 index a808608c..00000000 --- a/ui/src/components/HoloLogin.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/ui/src/utils/client.ts b/ui/src/utils/client.ts index 7ee20067..70ed1e93 100644 --- a/ui/src/utils/client.ts +++ b/ui/src/utils/client.ts @@ -4,7 +4,7 @@ import { CellType, AppAgentWebsocket, } from "@holochain/client"; -import WebSdkApi from "@holo-host/web-sdk"; +import WebSdkApi, { AgentState } from "@holo-host/web-sdk"; export const HOLOCHAIN_APP_ID = "mewsfeed"; export const IS_LAUNCHER = import.meta.env.VITE_IS_LAUNCHER; @@ -46,6 +46,16 @@ export const setupHolo = async () => { }, }); + await new Promise((resolve) => + client.on("agent-state", (state: AgentState) => { + if (state.isAvailable && state.isAnonymous) { + client.signUp({}); + } else if (state.isAvailable && !state.isAnonymous) { + resolve(state); + } + }) + ); + return client; } catch (e) { console.log("Holo client setup error", e);