mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
completely removed modal reducer
This commit is contained in:
parent
b1e8bddbaf
commit
8d5afb4f98
34 changed files with 189 additions and 300 deletions
|
@ -1,10 +1,18 @@
|
|||
import { makeAutoObservable } from 'mobx';
|
||||
import { FlowStore } from '~/store/flow/FlowStore';
|
||||
import { ModalStore } from '~/store/modal/ModalStore';
|
||||
import { PhotoSwipeStore } from '~/store/photoSwipe/PhotoSwipeStore';
|
||||
|
||||
export class Store {
|
||||
flow = new FlowStore();
|
||||
modal = new ModalStore();
|
||||
photoSwipe = new PhotoSwipeStore();
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
}
|
||||
|
||||
const defaultStore = new Store();
|
||||
|
||||
export const getMOBXStore = () => defaultStore;
|
||||
|
|
14
src/store/modal/ModalStore.tsx
Normal file
14
src/store/modal/ModalStore.tsx
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { makeAutoObservable } from 'mobx';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
|
||||
export class ModalStore {
|
||||
current: Dialog | null = null;
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
setCurrent = (current: Dialog | null) => (this.current = current);
|
||||
|
||||
hide = () => (this.current = null);
|
||||
}
|
3
src/store/modal/useModalStore.ts
Normal file
3
src/store/modal/useModalStore.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { useStore } from '~/utils/context/StoreContextProvider';
|
||||
|
||||
export const useModalStore = () => useStore().modal;
|
16
src/store/photoSwipe/PhotoSwipeStore.tsx
Normal file
16
src/store/photoSwipe/PhotoSwipeStore.tsx
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { makeAutoObservable } from 'mobx';
|
||||
import { IFile } from '~/redux/types';
|
||||
|
||||
export class PhotoSwipeStore {
|
||||
images: IFile[] = [];
|
||||
index: number = 0;
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
setData = (images: IFile[], index: number) => {
|
||||
this.images = images;
|
||||
this.index = index;
|
||||
};
|
||||
}
|
3
src/store/photoSwipe/usePhotoSwipeStore.tsx
Normal file
3
src/store/photoSwipe/usePhotoSwipeStore.tsx
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { useStore } from '~/utils/context/StoreContextProvider';
|
||||
|
||||
export const usePhotoSwipeStore = () => useStore().photoSwipe;
|
Loading…
Add table
Add a link
Reference in a new issue