diff --git a/packages/dui3/app.vue b/packages/dui3/app.vue
index c306bfa05..128747049 100644
--- a/packages/dui3/app.vue
+++ b/packages/dui3/app.vue
@@ -6,6 +6,12 @@
diff --git a/packages/dui3/components/user/Avatar.vue b/packages/dui3/components/user/Avatar.vue
new file mode 100644
index 000000000..a5821f3fc
--- /dev/null
+++ b/packages/dui3/components/user/Avatar.vue
@@ -0,0 +1,10 @@
+
+ Hello avatar!
+
+
diff --git a/packages/dui3/lib/accounts/composables/setup.ts b/packages/dui3/lib/accounts/composables/setup.ts
index c301f67c5..661b0383b 100644
--- a/packages/dui3/lib/accounts/composables/setup.ts
+++ b/packages/dui3/lib/accounts/composables/setup.ts
@@ -18,8 +18,10 @@ export type DUIAccountsState = {
}
const AccountsInjectionKey = 'DUI_ACCOUNTS_STATE'
-
-export async function useAccountsSetup(): Promise {
+/**
+ * Use this composable to set up the account bindings and graphql clients at the top of the app.
+ */
+export function useAccountsSetup(): DUIAccountsState {
const app = useNuxtApp()
const $baseBinding = app.$baseBinding
@@ -31,6 +33,8 @@ export async function useAccountsSetup(): Promise {
// Matches local accounts coming from the host app to app state.
const refreshAccounts = async () => {
const accs = await $baseBinding.getAccounts()
+ // We create a whole new list of accounts that will replace the old list. This way we ensure we drop
+ // out of scope old accounts that not exist anymore (TODO: test), and we don't need to do complex diffing.
const newAccs = [] as DUIAccount[]
for (const acc of accs) {
const existing = accounts.value.find((a) => a.accountInfo.id === acc.id)
@@ -45,7 +49,9 @@ export async function useAccountsSetup(): Promise {
authToken: () => acc.token
})
)
+
apolloClients[acc.id] = client
+
newAccs.push({
accountInfo: acc,
client
@@ -54,7 +60,7 @@ export async function useAccountsSetup(): Promise {
accounts.value = newAccs
}
- await refreshAccounts()
+ ;(async () => await refreshAccounts())()
const defaultAccount = computed(() =>
accounts.value.find((acc) => acc.accountInfo.isDefault)
@@ -71,6 +77,9 @@ export async function useAccountsSetup(): Promise {
return accState
}
+/**
+ * Use this composable to access the users' local accounts and their corresponding graphql client.
+ */
export function useInjectedAccounts(): DUIAccountsState {
const state = inject(AccountsInjectionKey) as DUIAccountsState
return state
diff --git a/packages/dui3/lib/document-info/index.ts b/packages/dui3/lib/document-info/index.ts
index ff7f00118..a65b89c57 100644
--- a/packages/dui3/lib/document-info/index.ts
+++ b/packages/dui3/lib/document-info/index.ts
@@ -1,20 +1,19 @@
import { DocumentInfo } from '~/lib/bindings/definitions/baseBindings'
import { ref } from 'vue'
-const DocumentInfoInjectionKey = 'DUI_ACCOUNTS_STATE'
+const DocumentInfoInjectionKey = 'DUI_DOC_INFO_STATE'
-export async function useDocumentInfoSetup() {
+export function useDocumentInfoSetup() {
const app = useNuxtApp()
const documentInfo = ref()
- app.$baseBinding.on('documentChanged', () => {
+ app.$baseBinding?.on('documentChanged', () => {
setTimeout(async () => {
const docInfo = await app.$baseBinding.getDocumentInfo()
documentInfo.value = docInfo
- }, 500) // Don't ask
+ }, 500) // Rhino needs some time.
})
-
- documentInfo.value = await app.$baseBinding.getDocumentInfo()
+ ;(async () => (documentInfo.value = await app.$baseBinding.getDocumentInfo()))()
provide(DocumentInfoInjectionKey, documentInfo)
return documentInfo
}
diff --git a/packages/dui3/pages/index.vue b/packages/dui3/pages/index.vue
index cdf848732..bf286ca1d 100644
--- a/packages/dui3/pages/index.vue
+++ b/packages/dui3/pages/index.vue
@@ -39,17 +39,17 @@