pleroma-fe/src/stores/statusHistory.js

34 lines
758 B
JavaScript
Raw Normal View History

2023-04-05 14:13:28 -06:00
import { defineStore } from 'pinia'
2026-08-18 18:00:36 +03:00
import { useOAuthStore } from 'src/stores/oauth.js'
import { fetchStatusHistory } from 'src/api/public.js'
2023-04-05 14:13:28 -06:00
export const useStatusHistoryStore = defineStore('statusHistory', {
state: () => ({
2026-08-18 18:00:36 +03:00
id: null,
2026-01-06 16:22:52 +02:00
modalActivated: false,
2026-08-18 18:00:36 +03:00
history: null,
2023-04-05 14:13:28 -06:00
}),
actions: {
2026-08-18 18:00:36 +03:00
openModal(id) {
this.fetchStatusHistory(id).then(() => {
this.id = id
this.modalActivated = true
})
2023-04-05 14:13:28 -06:00
},
2026-08-18 18:00:36 +03:00
closeModal() {
this.id = null
2023-04-05 14:13:28 -06:00
this.modalActivated = false
2026-08-18 18:00:36 +03:00
this.history = null
},
fetchStatusHistory(id) {
return fetchStatusHistory({
id,
credentials: useOAuthStore().token,
}).then(({ data }) => {
this.history = data
})
2026-01-06 16:22:52 +02:00
},
},
2023-04-05 14:13:28 -06:00
})