Skip to content

Commit

Permalink
fix(ui): remove unnecessary HoloLogin component, await holo client si…
Browse files Browse the repository at this point in the history
…gnals to trigger signup and resolve client setup
  • Loading branch information
mattyg committed Aug 29, 2023
1 parent 435ea9f commit 5554a51
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 38 deletions.
7 changes: 1 addition & 6 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
class="w-full flex justify-center items-center relative font-content cursor-default"
>
<profiles-context :store="profilesStore">
<HoloLogin v-if="IS_HOLO_HOSTED">
<MainLayout />
</HoloLogin>

<MainLayout v-else />
<MainLayout />

<div
v-if="loadingCells"
Expand All @@ -32,7 +28,6 @@
<script setup lang="ts">
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";
Expand Down
31 changes: 0 additions & 31 deletions ui/src/components/HoloLogin.vue

This file was deleted.

12 changes: 11 additions & 1 deletion ui/src/utils/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5554a51

Please sign in to comment.