chore: extract getting all tokens into a composable

This commit is contained in:
kolaente 2021-12-14 21:36:42 +01:00 committed by Dominik Pschenitschni
parent 354775fbb4
commit 524da627d5
Signed by: dpschen
GPG Key ID: B257AC0149F43A77
1 changed files with 10 additions and 7 deletions

View File

@ -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<CaldavTokenModel[]>([])
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<CaldavTokenModel[]>([])
service.getAll()
.then((r: CaldavTokenModel[]) => {
tokens.value = r
})
const newToken = ref(null)
const createToken = async () => {
const r = await service.create({})