clear old value after migration
This commit is contained in:
parent
318543872a
commit
29aacf5b7e
2 changed files with 11 additions and 2 deletions
|
|
@ -115,6 +115,9 @@ export const uiSlice = createSlice({
|
|||
) => {
|
||||
state.toolSettings[action.payload.toolName] = action.payload.policy;
|
||||
},
|
||||
clearToolPolicy: (state, action: PayloadAction<string>) => {
|
||||
delete state.toolSettings[action.payload];
|
||||
},
|
||||
toggleToolSetting: (state, action: PayloadAction<string>) => {
|
||||
const setting = state.toolSettings[action.payload];
|
||||
|
||||
|
|
@ -176,6 +179,7 @@ export const {
|
|||
setHasDismissedExploreDialog,
|
||||
toggleToolSetting,
|
||||
setToolPolicy,
|
||||
clearToolPolicy,
|
||||
toggleToolGroupSetting,
|
||||
addTool,
|
||||
addRule,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import { BuiltInToolNames } from "core/tools/builtIn";
|
||||
import { setToolPolicy, ToolPolicy } from "../redux/slices/uiSlice";
|
||||
import {
|
||||
clearToolPolicy,
|
||||
setToolPolicy,
|
||||
ToolPolicy,
|
||||
} from "../redux/slices/uiSlice";
|
||||
import { AppDispatch } from "../redux/store";
|
||||
|
||||
const validPolicyValues: ToolPolicy[] = [
|
||||
|
|
@ -39,7 +43,7 @@ function migrateToolPolicies(dispatch: AppDispatch) {
|
|||
if (parsedSettings) {
|
||||
let migratedToolSettings = 0;
|
||||
Object.entries(toFromMap).forEach(([newToolName, oldToolNames]) => {
|
||||
for (const tool in oldToolNames) {
|
||||
for (const tool of oldToolNames) {
|
||||
if (
|
||||
tool in parsedSettings &&
|
||||
validPolicyValues.includes(parsedSettings[tool])
|
||||
|
|
@ -50,6 +54,7 @@ function migrateToolPolicies(dispatch: AppDispatch) {
|
|||
policy: parsedSettings[tool],
|
||||
}),
|
||||
);
|
||||
dispatch(clearToolPolicy(tool));
|
||||
migratedToolSettings++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue