2019-07-16 16:04:43 +02:00
|
|
|
import { MutationTree } from "vuex";
|
2019-07-16 16:43:29 +02:00
|
|
|
import { AppState, FetchStatus, EventFeed, FeedInfo } from "./types";
|
2019-07-16 16:04:43 +02:00
|
|
|
|
|
|
|
const mutations: MutationTree<AppState> = {
|
2019-07-16 16:43:29 +02:00
|
|
|
appendSources(state, payload: EventFeed[]) {
|
2019-07-16 16:04:43 +02:00
|
|
|
// 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 };
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-07-16 16:43:29 +02:00
|
|
|
setSourceStatus(
|
|
|
|
state,
|
|
|
|
payload: { url: string; info?: FeedInfo; status: FetchStatus }
|
|
|
|
) {
|
2019-07-16 16:04:43 +02:00
|
|
|
state.status[payload.url] = payload.status;
|
2019-07-16 16:43:29 +02:00
|
|
|
if (payload.info) {
|
|
|
|
let source = state.sources.find(x => x.url == payload.url);
|
|
|
|
if (source) {
|
|
|
|
source.info = payload.info;
|
|
|
|
}
|
|
|
|
}
|
2019-07-16 16:04:43 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default mutations;
|