mirror of
https://github.com/usatiuk/writer.git
synced 2025-10-29 00:17:48 +01:00
autosave docs #5
This commit is contained in:
@@ -115,6 +115,8 @@ export const docsReducer: Reducer<IDocsState, DocsAction> = (
|
||||
name: payload.name,
|
||||
dirty: false,
|
||||
};
|
||||
const dirtyDocs = Object.values(all).filter(e => e.dirty);
|
||||
dirty = dirtyDocs.length > 0;
|
||||
}
|
||||
return { ...state, all, dirty };
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
newDocSuccess,
|
||||
showDocsSpinner,
|
||||
uploadDocsFail,
|
||||
uploadDocsStart,
|
||||
uploadDocsSuccess,
|
||||
} from "./actions";
|
||||
|
||||
@@ -170,6 +171,13 @@ function* docsUploadStart(action: IDocsUploadStartAction) {
|
||||
}
|
||||
}
|
||||
|
||||
export function* uploadDocsTimer() {
|
||||
while (true) {
|
||||
yield docsUploadStart(uploadDocsStart());
|
||||
yield delay(5000);
|
||||
}
|
||||
}
|
||||
|
||||
export function* docsSaga() {
|
||||
yield all([
|
||||
takeLatest(DocsTypes.DOCS_FETCH_START, docsFetchStart),
|
||||
|
||||
@@ -6,7 +6,7 @@ import { rootReducer } from "~redux/reducers";
|
||||
|
||||
import { setToken } from "./api/utils";
|
||||
import { authSaga } from "./auth/sagas";
|
||||
import { docsSaga } from "./docs/sagas";
|
||||
import { docsSaga, uploadDocsTimer } from "./docs/sagas";
|
||||
import { getUser } from "./user/actions";
|
||||
import { userSaga } from "./user/sagas";
|
||||
|
||||
@@ -28,3 +28,4 @@ export const persistor = persistStore(store, null, () => {
|
||||
sagaMiddleware.run(authSaga);
|
||||
sagaMiddleware.run(userSaga);
|
||||
sagaMiddleware.run(docsSaga);
|
||||
sagaMiddleware.run(uploadDocsTimer);
|
||||
|
||||
Reference in New Issue
Block a user