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,
|
name: payload.name,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
};
|
};
|
||||||
|
const dirtyDocs = Object.values(all).filter(e => e.dirty);
|
||||||
|
dirty = dirtyDocs.length > 0;
|
||||||
}
|
}
|
||||||
return { ...state, all, dirty };
|
return { ...state, all, dirty };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
newDocSuccess,
|
newDocSuccess,
|
||||||
showDocsSpinner,
|
showDocsSpinner,
|
||||||
uploadDocsFail,
|
uploadDocsFail,
|
||||||
|
uploadDocsStart,
|
||||||
uploadDocsSuccess,
|
uploadDocsSuccess,
|
||||||
} from "./actions";
|
} from "./actions";
|
||||||
|
|
||||||
@@ -170,6 +171,13 @@ function* docsUploadStart(action: IDocsUploadStartAction) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function* uploadDocsTimer() {
|
||||||
|
while (true) {
|
||||||
|
yield docsUploadStart(uploadDocsStart());
|
||||||
|
yield delay(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function* docsSaga() {
|
export function* docsSaga() {
|
||||||
yield all([
|
yield all([
|
||||||
takeLatest(DocsTypes.DOCS_FETCH_START, docsFetchStart),
|
takeLatest(DocsTypes.DOCS_FETCH_START, docsFetchStart),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { rootReducer } from "~redux/reducers";
|
|||||||
|
|
||||||
import { setToken } from "./api/utils";
|
import { setToken } from "./api/utils";
|
||||||
import { authSaga } from "./auth/sagas";
|
import { authSaga } from "./auth/sagas";
|
||||||
import { docsSaga } from "./docs/sagas";
|
import { docsSaga, uploadDocsTimer } from "./docs/sagas";
|
||||||
import { getUser } from "./user/actions";
|
import { getUser } from "./user/actions";
|
||||||
import { userSaga } from "./user/sagas";
|
import { userSaga } from "./user/sagas";
|
||||||
|
|
||||||
@@ -28,3 +28,4 @@ export const persistor = persistStore(store, null, () => {
|
|||||||
sagaMiddleware.run(authSaga);
|
sagaMiddleware.run(authSaga);
|
||||||
sagaMiddleware.run(userSaga);
|
sagaMiddleware.run(userSaga);
|
||||||
sagaMiddleware.run(docsSaga);
|
sagaMiddleware.run(docsSaga);
|
||||||
|
sagaMiddleware.run(uploadDocsTimer);
|
||||||
|
|||||||
Reference in New Issue
Block a user