first commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { writable } from "svelte/store";
|
||||
import stuffLogClient from "../clients/stufflog";
|
||||
import type { GroupResult } from "../models/group";
|
||||
|
||||
interface GroupStoreData {
|
||||
loading: boolean
|
||||
stale: boolean
|
||||
groups: GroupResult[]
|
||||
}
|
||||
|
||||
function createGroupStore() {
|
||||
const {update, subscribe} = writable<GroupStoreData>({
|
||||
loading: false,
|
||||
stale: true,
|
||||
groups: [],
|
||||
});
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
||||
markStale() {
|
||||
update(v => ({...v, stale: true}));
|
||||
},
|
||||
|
||||
async load() {
|
||||
update(v => ({...v, loading: true}));
|
||||
const groups = await stuffLogClient.listGroups();
|
||||
update(v => ({...v, loading: false, stale: false, groups}));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const groupStore = createGroupStore();
|
||||
|
||||
export default groupStore;
|
||||
Reference in New Issue
Block a user