mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- fix: persist table-sort params and cluster-view's sidebar state to lens-local-storage
- new-feature: auto-open main-window's devtools in development-mode (yes/no/ugly?) Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
749eb4a42b
commit
cf664de29b
@ -1,5 +1,5 @@
|
||||
import type { ClusterId } from "../common/cluster-store";
|
||||
import { observable, makeObservable } from "mobx";
|
||||
import { makeObservable, observable } from "mobx";
|
||||
import { app, BrowserWindow, dialog, shell, webContents } from "electron";
|
||||
import windowStateKeeper from "electron-window-state";
|
||||
import { appEventBus } from "../common/event-bus";
|
||||
@ -10,7 +10,7 @@ import { Singleton } from "../common/utils";
|
||||
import { ClusterFrameInfo, clusterFrameMap } from "../common/cluster-frames";
|
||||
import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
||||
import logger from "./logger";
|
||||
import { productName } from "../common/vars";
|
||||
import { isDevelopment, productName } from "../common/vars";
|
||||
import { LensProxy } from "./proxy/lens-proxy";
|
||||
|
||||
export class WindowManager extends Singleton {
|
||||
@ -85,7 +85,7 @@ export class WindowManager extends Singleton {
|
||||
shell.openExternal(url);
|
||||
})
|
||||
.on("dom-ready", () => {
|
||||
// this.mainWindow.webContents.openDevTools({ mode: "right", activate: !isProduction });
|
||||
this.mainWindow.webContents.openDevTools({ mode: "right", activate: isDevelopment });
|
||||
appEventBus.emit({ name: "app", action: "dom-ready" });
|
||||
})
|
||||
.on("did-fail-load", (_event, code, desc) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Helper for working with storages (e.g. window.localStorage, NodeJS/file-system, etc.)
|
||||
|
||||
import { action, makeObservable, observable, toJS, when, } from "mobx";
|
||||
import { action, comparer, makeObservable, observable, toJS, when, } from "mobx";
|
||||
import produce, { Draft } from "immer";
|
||||
import { isEqual, isFunction, isPlainObject } from "lodash";
|
||||
import logger from "../../main/logger";
|
||||
@ -21,9 +21,13 @@ export interface StorageHelperOptions<T> {
|
||||
|
||||
export class StorageHelper<T> {
|
||||
static logPrefix = "[StorageHelper]:";
|
||||
|
||||
readonly storage: StorageAdapter<T>;
|
||||
private data = observable.box<T>();
|
||||
|
||||
private data = observable.box<T>(undefined, {
|
||||
deep: true,
|
||||
equals: comparer.structural,
|
||||
});
|
||||
|
||||
@observable initialized = false;
|
||||
|
||||
get whenReady() {
|
||||
@ -39,6 +43,7 @@ export class StorageHelper<T> {
|
||||
makeObservable(this);
|
||||
|
||||
const { storage, autoInit = true } = options;
|
||||
|
||||
this.storage = storage;
|
||||
|
||||
this.data.observe_(({ newValue, oldValue }) => {
|
||||
@ -124,7 +129,7 @@ export class StorageHelper<T> {
|
||||
|
||||
@action
|
||||
merge(value: Partial<T> | ((draft: Draft<T>) => Partial<T> | void)) {
|
||||
const nextValue = produce(this.get(), (state: Draft<T>) => {
|
||||
const nextValue = produce(this.toJSON(), (state: Draft<T>) => {
|
||||
const newValue = isFunction(value) ? value(state) : value;
|
||||
|
||||
return isPlainObject(newValue)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user