pleroma-fe/src/stores/follow_requests.js

38 lines
967 B
JavaScript
Raw Normal View History

import { defineStore } from 'pinia'
import followRequestFetcher from 'src/stores/fetchers/follow_requests.js'
import { useOAuthStore } from 'src/stores/oauth.js'
export const useFollowRequestsStore = defineStore('followRequests', {
state: () => ({
fetcher: null,
requests: new Map(),
}),
getters: {
followRequestsCount(state) {
return state.requests.size
},
},
actions: {
startFetching() {
2026-09-03 16:55:41 +03:00
if (this.fetcher) throw new Error('Fetcher already exists!')
this.fetcher = followRequestFetcher({
credentials: useOAuthStore().token,
})
this.fetcher.startFetching()
},
stopFetching() {
2026-09-03 16:55:41 +03:00
if (!this.fetcher) throw new Error("Fetcher doesn't exists!")
this.fetcher.stopFetching()
this.fetcher = null
},
setFollowRequests(requests) {
this.requests = new Map(requests.map((user) => [user.id, user]))
},
remove(id) {
this.requests.delete(id)
2026-09-01 18:02:38 +03:00
},
},
})