From 043bf62ef38555cca91f45cc9794cd071da15cd0 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 14 Dec 2021 21:36:42 +0100 Subject: [PATCH] chore: extract getting all tokens into a composable --- src/views/user/settings/Caldav.vue | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/views/user/settings/Caldav.vue b/src/views/user/settings/Caldav.vue index 6d887a96..3c7d5a47 100644 --- a/src/views/user/settings/Caldav.vue +++ b/src/views/user/settings/Caldav.vue @@ -78,6 +78,16 @@ import Message from '@/components/misc/message.vue' import CaldavTokenService from '@/services/caldavToken' import CaldavTokenModel from '@/models/caldavToken' +const service = new CaldavTokenService() + +async function useToken() { + const tokens = ref([]) + tokens.value = await service.getAll() + return tokens +} + +const tokens = useToken() + const store = useStore() const {t} = useI18n() @@ -88,13 +98,6 @@ const caldavEnabled = computed(() => store.state.config.caldavEnabled) const isLocalUser = computed(() => store.state.auth.info?.isLocalUser) const username = computed(() => store.state.auth.info?.username) -const service = new CaldavTokenService() -const tokens = ref([]) -service.getAll() - .then((r: CaldavTokenModel[]) => { - tokens.value = r - }) - const newToken = ref(null) const createToken = async () => { const r = await service.create({})