ui: simplify scratchpad countdown logic (#373)

This commit is contained in:
undefined authored and GitHub committed 2022-06-25 17:46:07 +08:00
1 parent 8fc64a0654
commit cb18ec19fe
3 files changed
+17 -29

No files matched your search

@@ -17,6 +17,7 @@ export default function reducer(state = {
isLoading: false,
},
isPosting: false,
waitSec: 0,
isWaiting: false,
}, action) {
switch (action.type) {
@@ -68,6 +69,7 @@ export default function reducer(state = {
return {
...state,
isPosting: false,
waitSec: 5,
isWaiting: true,
};
}
@@ -77,9 +79,17 @@ export default function reducer(state = {
return {
...state,
isPosting: false,
waitSec: 5,
isWaiting: true,
};
}
case 'SCRATCHPAD_WAITING_TICK': {
return {
...state,
waitSec: state.waitSec - 1,
isWaiting: state.waitSec > 1,
};
}
case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_PENDING': {
return {
...state,
@@ -108,12 +118,6 @@ export default function reducer(state = {
},
};
}
case 'SCRATCHPAD_WAITING_END': {
return {
...state,
isWaiting: false,
};
}
default:
return state;
}