mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
attempt to fix immer/merge bug (#4107)
Co-authored-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
e643b37c7f
commit
169f443c3b
@ -22,7 +22,7 @@
|
|||||||
// Helper for working with storages (e.g. window.localStorage, NodeJS/file-system, etc.)
|
// Helper for working with storages (e.g. window.localStorage, NodeJS/file-system, etc.)
|
||||||
import { action, comparer, makeObservable, observable, toJS, when, } from "mobx";
|
import { action, comparer, makeObservable, observable, toJS, when, } from "mobx";
|
||||||
import produce, { Draft, isDraft } from "immer";
|
import produce, { Draft, isDraft } from "immer";
|
||||||
import { isEqual } from "lodash";
|
import { isEqual, isPlainObject } from "lodash";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../main/logger";
|
||||||
|
|
||||||
export interface StorageAdapter<T> {
|
export interface StorageAdapter<T> {
|
||||||
@ -80,7 +80,7 @@ export class StorageHelper<T> {
|
|||||||
const notDefault = !this.isDefaultValue(data);
|
const notDefault = !this.isDefaultValue(data);
|
||||||
|
|
||||||
if (notEmpty && notDefault) {
|
if (notEmpty && notDefault) {
|
||||||
this.merge(data);
|
this.set(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
@ -159,9 +159,11 @@ export class StorageHelper<T> {
|
|||||||
if (newValue && !isDraft(newValue)) {
|
if (newValue && !isDraft(newValue)) {
|
||||||
Object.assign(draft, newValue);
|
Object.assign(draft, newValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (isPlainObject(value)) {
|
||||||
Object.assign(draft, value);
|
Object.assign(draft, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return draft;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.set(nextValue);
|
this.set(nextValue);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user