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:
parent
5f3accee48
commit
38eedab3c2
26 changed files with 326 additions and 310 deletions
33
src/store/flow/FlowStore.ts
Normal file
33
src/store/flow/FlowStore.ts
Normal 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)));
|
||||
};
|
||||
}
|
3
src/store/flow/useFlowStore.ts
Normal file
3
src/store/flow/useFlowStore.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { useStore } from '~/utils/context/StoreContextProvider';
|
||||
|
||||
export const useFlowStore = () => useStore().flow;
|
10
src/store/index.ts
Normal file
10
src/store/index.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { makeAutoObservable } from 'mobx';
|
||||
import { FlowStore } from '~/store/flow/FlowStore';
|
||||
|
||||
export class Store {
|
||||
flow = new FlowStore();
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue