1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

completely removed flow-related sagas

This commit is contained in:
Fedor Katurov 2022-01-04 15:08:20 +07:00
parent 5f3accee48
commit 38eedab3c2
26 changed files with 326 additions and 310 deletions

View file

@ -0,0 +1,33 @@
import { makeAutoObservable } from 'mobx';
import { IFlowNode } from '~/redux/types';
export class FlowStore {
nodes: IFlowNode[] = [];
heroes: IFlowNode[] = [];
recent: IFlowNode[] = [];
updated: IFlowNode[] = [];
/** if store was updated after rehydration */
isRefreshed = false;
constructor() {
makeAutoObservable(this);
}
setNodes = (nodes: IFlowNode[]) => (this.nodes = nodes);
setHeroes = (heroes: IFlowNode[]) => (this.heroes = heroes);
setRecent = (recent: IFlowNode[]) => (this.recent = recent);
setUpdated = (updated: IFlowNode[]) => (this.updated = updated);
setIsRefreshed = (refreshed: boolean) => (this.isRefreshed = refreshed);
/** removes node from updated after user seen it */
seenNode = (nodeId: number) => {
this.setUpdated(this.updated.filter(node => node.id !== nodeId));
};
/** replaces node with value */
updateNode = (id: number, node: Partial<IFlowNode>) => {
this.setNodes(this.nodes.map(it => (it.id === id ? { ...it, ...node } : it)));
};
}

View file

@ -0,0 +1,3 @@
import { useStore } from '~/utils/context/StoreContextProvider';
export const useFlowStore = () => useStore().flow;

10
src/store/index.ts Normal file
View file

@ -0,0 +1,10 @@
import { makeAutoObservable } from 'mobx';
import { FlowStore } from '~/store/flow/FlowStore';
export class Store {
flow = new FlowStore();
constructor() {
makeAutoObservable(this);
}
}