fix(commands): narrow deferred history policy
This commit is contained in:
@@ -59,13 +59,15 @@ function applyHistoryPolicy(options: {
|
|||||||
getDeferredHistory: () => { snapshot: HistorySnapshot; changed: boolean } | undefined;
|
getDeferredHistory: () => { snapshot: HistorySnapshot; changed: boolean } | undefined;
|
||||||
setDeferredHistory: (nextDeferredHistory: { snapshot: HistorySnapshot; changed: boolean } | undefined) => void;
|
setDeferredHistory: (nextDeferredHistory: { snapshot: HistorySnapshot; changed: boolean } | undefined) => void;
|
||||||
}): AppState {
|
}): AppState {
|
||||||
if (options.historyPolicy.mode === "ignore") {
|
const { historyPolicy } = options;
|
||||||
|
|
||||||
|
if (historyPolicy.mode === "ignore") {
|
||||||
options.setDeferredHistory(undefined);
|
options.setDeferredHistory(undefined);
|
||||||
return options.nextState;
|
return options.nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.historyPolicy.mode === "deferred") {
|
if (historyPolicy.mode === "deferred") {
|
||||||
return applyDeferredHistoryPolicy(options);
|
return applyDeferredHistoryPolicy({ ...options, historyPolicy });
|
||||||
}
|
}
|
||||||
|
|
||||||
return shouldRecordHistory(options.currentState, options.nextState) ? recordHistory(snapshot(options.currentState), options.nextState) : options.nextState;
|
return shouldRecordHistory(options.currentState, options.nextState) ? recordHistory(snapshot(options.currentState), options.nextState) : options.nextState;
|
||||||
|
|||||||
Reference in New Issue
Block a user