Migrate oauth tokens module to pinia store

This commit is contained in:
Sean King 2025-05-10 22:35:15 -06:00
commit 27f753e8de
No known key found for this signature in database
GPG key ID: 510C52BACD6E7257
7 changed files with 32 additions and 33 deletions

View file

@ -0,0 +1,24 @@
import { defineStore } from 'pinia'
export const useOAuthTokensStore = defineStore('oauthTokens', {
state: () => ({
tokens: []
}),
actions: {
fetchTokens () {
window.vuex.state.api.backendInteractor.fetchOAuthTokens().then((tokens) => {
this.swapTokens(tokens)
})
},
revokeToken (id) {
window.vuex.state.api.backendInteractor.revokeOAuthToken({ id }).then((response) => {
if (response.status === 201) {
this.swapTokens(this.tokens.filter(token => token.id !== id))
}
})
},
swapTokens (tokens) {
this.tokens = tokens
}
}
});