diretto/src/store/mutations.ts

30 lines
755 B
TypeScript

import { MutationTree } from "vuex";
import { AppState, FetchStatus, EventFeed, FeedInfo } from "./types";
const mutations: MutationTree<AppState> = {
appendSources(state, payload: EventFeed[]) {
// Add sources to list
state.sources = state.sources.concat(payload);
// Set "loading" state for all of them
payload.forEach(x => {
state.status[x.url] = { fetched: false };
});
},
setSourceStatus(
state,
payload: { url: string; info?: FeedInfo; status: FetchStatus }
) {
state.status[payload.url] = payload.status;
if (payload.info) {
let source = state.sources.find(x => x.url == payload.url);
if (source) {
source.info = payload.info;
}
}
}
};
export default mutations;