diff --git a/ui/src/component/LoadingSpinner.vue b/ui/src/component/LoadingSpinner.vue index 0d03f24..c85f8e5 100644 --- a/ui/src/component/LoadingSpinner.vue +++ b/ui/src/component/LoadingSpinner.vue @@ -8,11 +8,25 @@ defineProps<{ + + diff --git a/ui/src/store/key-collections-store.ts b/ui/src/store/key-collections-store.ts index 19e0c66..4eda5a8 100644 --- a/ui/src/store/key-collections-store.ts +++ b/ui/src/store/key-collections-store.ts @@ -10,6 +10,7 @@ export interface KeyCollectionWithKeys { } export const useKeyCollectionsStore = defineStore("key-collections", () => { + const loading = ref(true); const keyCollections = ref([]); const pushKeyCollection = (collection: KeyCollectionWithKeys) => { @@ -27,15 +28,22 @@ export const useKeyCollectionsStore = defineStore("key-collections", () => { const client = inject("client") as ComputedRef; const loadKeyCollections = async (client: AppAgentClient) => { - const collections: KeyCollectionWithKeys[] = await client.callZome({ - role_name: "trusted", - zome_name: "trusted", - fn_name: "get_my_key_collections", - payload: null, - cap_secret: null, - }); - - keyCollections.value = [...collections, ...keyCollections.value]; + try { + const collections: KeyCollectionWithKeys[] = await client.callZome({ + role_name: "trusted", + zome_name: "trusted", + fn_name: "get_my_key_collections", + payload: null, + cap_secret: null, + }); + + keyCollections.value = [...collections, ...keyCollections.value]; + } catch (e) { + // TODO Don't have the notifications store here, can I use it? + console.error("Error loading key collections", e); + } finally { + loading.value = false; + } }; watch( @@ -51,6 +59,7 @@ export const useKeyCollectionsStore = defineStore("key-collections", () => { ); return { + loading, keyCollections, pushKeyCollection, addKeyToCollection, diff --git a/ui/src/store/my-keys-store.ts b/ui/src/store/my-keys-store.ts index aa17977..64f1019 100644 --- a/ui/src/store/my-keys-store.ts +++ b/ui/src/store/my-keys-store.ts @@ -32,9 +32,7 @@ export const useMyKeysStore = defineStore("my-keys", () => { // TODO Don't have the notifications store here, can I use it? console.error("Error loading keys", e); } finally { - setTimeout(() => { - loading.value = false; - }, 250) + loading.value = false; } }; diff --git a/ui/src/trusted/trusted/KeyCollections.vue b/ui/src/trusted/trusted/KeyCollections.vue index 753c435..f8374c3 100644 --- a/ui/src/trusted/trusted/KeyCollections.vue +++ b/ui/src/trusted/trusted/KeyCollections.vue @@ -1,29 +1,41 @@ diff --git a/ui/src/trusted/trusted/MyKeys.vue b/ui/src/trusted/trusted/MyKeys.vue index cc61dc8..ee63523 100644 --- a/ui/src/trusted/trusted/MyKeys.vue +++ b/ui/src/trusted/trusted/MyKeys.vue @@ -2,7 +2,7 @@ import { useMyKeysStore } from "../../store/my-keys-store"; import KeyList from "../../component/KeyList.vue"; import DistributeGpgKey from "./DistributeGpgKey.vue"; -import { computed, ref, watch } from "vue"; +import { ref, watch } from "vue"; import LoadingSpinner from "../../component/LoadingSpinner.vue"; import { storeToRefs } from "pinia"; @@ -12,6 +12,7 @@ const showDistribute = ref(false); // Encourage the user to distribute a key if they don't have any yet watch(loading, (loading) => { + console.log(`loading: ${loading}, length ${myKeys.value.length}`) if (!loading && myKeys.value.length === 0) { showDistribute.value = true; } @@ -37,20 +38,22 @@ watch(loading, (loading) => {

Loading keys