mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix endless re-rending of logs
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
23 files changed
+354
-161
No files matched your search
@@ -20,7 +20,15 @@
|
||||
*/
|
||||
|
||||
// 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,
|
||||
computed,
|
||||
makeObservable,
|
||||
observable,
|
||||
toJS,
|
||||
when,
|
||||
} from "mobx";
|
||||
import produce, { Draft, isDraft } from "immer";
|
||||
import { isEqual, isPlainObject } from "lodash";
|
||||
import logger from "../../main/logger";
|
||||
@@ -66,10 +74,6 @@ export class StorageHelper<T> {
|
||||
|
||||
this.storage = storage;
|
||||
|
||||
this.data.observe_(({ newValue, oldValue }) => {
|
||||
this.onChange(newValue as T, oldValue as T);
|
||||
});
|
||||
|
||||
if (autoInit) {
|
||||
this.init();
|
||||
}
|
||||
@@ -130,16 +134,25 @@ export class StorageHelper<T> {
|
||||
}
|
||||
|
||||
get(): T {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@computed
|
||||
get value(): T {
|
||||
return this.data.get() ?? this.defaultValue;
|
||||
}
|
||||
|
||||
@action
|
||||
set(value: T) {
|
||||
if (this.isDefaultValue(value)) {
|
||||
set(newValue: T) {
|
||||
const oldValue = this.value;
|
||||
|
||||
if (this.isDefaultValue(newValue)) {
|
||||
this.reset();
|
||||
} else {
|
||||
this.data.set(value);
|
||||
this.data.set(newValue);
|
||||
}
|
||||
|
||||
this.onChange(newValue, oldValue);
|
||||
}
|
||||
|
||||
@action
|
||||
|
||||
Reference in new issue
Block a user