Files
cellxgene/client/src/reducers/autosave.ts
T
Mim HastieandTimmy Huang 27575b8d86 Added @typescript-eslint/recommended config with suppressions (#2345)
* Disabled @blueprintjs/classes-constants. #2288.

* thuang-eslint-bp-off (#2344)

* Disabled @blueprintjs/classes-constants on webpack dev and shared. #2288.

* Added TS recommended, suppress lint errors codemod.

* Added per-error/warning ignore for tests.

* Added per-error/warning ignore for configuration.

* Added per-error/warning ignore for src. Removed suppress package.

* Minor linting.

Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
2021-07-28 16:06:34 -07:00

94 lines
2.3 KiB
TypeScript

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
const Autosave = (
state = {
// cell labels
obsAnnotationSaveInProgress: false,
lastSavedAnnoMatrix: null,
// gene sets
genesetSaveInProgress: false,
lastSavedGenesets: null,
// error state
error: false,
},
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
action: any,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
nextSharedState: any
) => {
switch (action.type) {
case "annoMatrix: init complete": {
return {
...state,
error: false,
obsAnnotationSaveInProgress: false,
lastSavedAnnoMatrix: action.annoMatrix,
};
}
case "writable obs annotations - save started": {
return {
...state,
obsAnnotationSaveInProgress: true,
};
}
case "writable obs annotations - save error": {
return {
...state,
error: action.message,
obsAnnotationSaveInProgress: false,
};
}
case "writable obs annotations - save complete": {
const { lastSavedAnnoMatrix } = action;
return {
...state,
obsAnnotationSaveInProgress: false,
error: false,
lastSavedAnnoMatrix,
};
}
case "geneset: initial load": {
return {
...state,
genesetSaveInProgress: false,
lastSavedGenesets: nextSharedState.genesets.genesets,
};
}
case "autosave: genesets started": {
return {
...state,
genesetSaveInProgress: true,
};
}
case "autosave: genesets error": {
return {
...state,
genesetSaveInProgress: false,
error: action.message,
};
}
case "autosave: genesets complete": {
const { lastSavedGenesets } = action;
return {
...state,
genesetSaveInProgress: false,
error: false,
lastSavedGenesets,
};
}
default:
return { ...state };
}
};
export default Autosave;