2020-04-10 19:41:08 +00:00
|
|
|
import { action, Action } from 'easy-peasy';
|
|
|
|
|
|
|
|
export interface ProgressStore {
|
|
|
|
continuous: boolean;
|
|
|
|
progress?: number;
|
|
|
|
|
|
|
|
startContinuous: Action<ProgressStore>;
|
|
|
|
setProgress: Action<ProgressStore, number | undefined>;
|
|
|
|
setComplete: Action<ProgressStore>;
|
|
|
|
}
|
|
|
|
|
|
|
|
const progress: ProgressStore = {
|
|
|
|
continuous: false,
|
|
|
|
progress: undefined,
|
|
|
|
|
2022-06-26 19:13:52 +00:00
|
|
|
startContinuous: action((state) => {
|
2020-04-10 19:41:08 +00:00
|
|
|
state.continuous = true;
|
|
|
|
}),
|
|
|
|
|
|
|
|
setProgress: action((state, payload) => {
|
|
|
|
state.progress = payload;
|
|
|
|
}),
|
|
|
|
|
2022-06-26 19:13:52 +00:00
|
|
|
setComplete: action((state) => {
|
2020-04-26 18:19:40 +00:00
|
|
|
if (state.progress) {
|
|
|
|
state.progress = 100;
|
|
|
|
}
|
|
|
|
|
2020-04-10 19:41:08 +00:00
|
|
|
state.continuous = false;
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
|
|
|
export default progress;
|