1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

More consistent use of BaseStore.displayName

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-12-01 08:16:22 -05:00
parent 0cf9f9e536
commit 8217ad4ba8
8 changed files with 6 additions and 16 deletions

View File

@ -40,22 +40,20 @@ export abstract class BaseStore<T extends object> {
protected storeConfig?: Config<T>; protected storeConfig?: Config<T>;
protected syncDisposers: Disposer[] = []; protected syncDisposers: Disposer[] = [];
readonly displayName = this.params.configName; readonly displayName = kebabCase(this.params.configName).toUpperCase();
protected constructor( protected constructor(
protected readonly dependencies: BaseStoreDependencies, protected readonly dependencies: BaseStoreDependencies,
protected readonly params: BaseStoreParams<T>, protected readonly params: BaseStoreParams<T>,
) { ) {
makeObservable(this); makeObservable(this);
this.displayName = this.params.configName;
} }
/** /**
* This must be called after the last child's constructor is finished (or just before it finishes) * This must be called after the last child's constructor is finished (or just before it finishes)
*/ */
load() { load() {
this.dependencies.logger.info(`[${kebabCase(this.displayName).toUpperCase()}]: LOADING ...`); this.dependencies.logger.info(`[${this.displayName}]: LOADING ...`);
this.storeConfig = this.dependencies.getConfigurationFileModel({ this.storeConfig = this.dependencies.getConfigurationFileModel({
projectName: "lens", projectName: "lens",
projectVersion: this.dependencies.storeMigrationVersion, projectVersion: this.dependencies.storeMigrationVersion,
@ -71,7 +69,7 @@ export abstract class BaseStore<T extends object> {
} }
this.enableSync(); this.enableSync();
this.dependencies.logger.info(`[${kebabCase(this.displayName).toUpperCase()}]: LOADED from ${this.path}`); this.dependencies.logger.info(`[${this.displayName}]: LOADED from ${this.path}`);
} }
get name() { get name() {
@ -95,7 +93,7 @@ export abstract class BaseStore<T extends object> {
} }
protected saveToFile(model: T) { protected saveToFile(model: T) {
this.dependencies.logger.info(`[STORE]: SAVING ${this.path}`); this.dependencies.logger.info(`[${this.displayName}]: SAVING ${this.path}`);
// todo: update when fixed https://github.com/sindresorhus/conf/issues/114 // todo: update when fixed https://github.com/sindresorhus/conf/issues/114
if (this.storeConfig) { if (this.storeConfig) {
@ -116,14 +114,14 @@ export abstract class BaseStore<T extends object> {
if (ipcMain) { if (ipcMain) {
this.syncDisposers.push(ipcMainOn(this.syncMainChannel, (event, model: T) => { this.syncDisposers.push(ipcMainOn(this.syncMainChannel, (event, model: T) => {
this.dependencies.logger.silly(`[STORE]: SYNC ${this.name} from renderer`, { model }); this.dependencies.logger.silly(`[${this.displayName}]: SYNC ${this.name} from renderer`, { model });
this.onSync(model); this.onSync(model);
})); }));
} }
if (ipcRenderer) { if (ipcRenderer) {
this.syncDisposers.push(ipcRendererOn(this.syncRendererChannel, (event, model: T) => { this.syncDisposers.push(ipcRendererOn(this.syncRendererChannel, (event, model: T) => {
this.dependencies.logger.silly(`[STORE]: SYNC ${this.name} from main`, { model }); this.dependencies.logger.silly(`[${this.displayName}]: SYNC ${this.name} from main`, { model });
this.onSyncFromMain(model); this.onSyncFromMain(model);
})); }));
} }

View File

@ -27,7 +27,6 @@ interface Dependencies extends BaseStoreDependencies {
} }
export class ClusterStore extends BaseStore<ClusterStoreModel> { export class ClusterStore extends BaseStore<ClusterStoreModel> {
readonly displayName = "ClusterStore";
readonly clusters = observable.map<ClusterId, Cluster>(); readonly clusters = observable.map<ClusterId, Cluster>();
protected readonly disposer = disposer(); protected readonly disposer = disposer();

View File

@ -27,7 +27,6 @@ interface Dependencies extends BaseStoreDependencies {
} }
export class HotbarStore extends BaseStore<HotbarStoreModel> { export class HotbarStore extends BaseStore<HotbarStoreModel> {
readonly displayName = "HotbarStore";
@observable hotbars: Hotbar[] = []; @observable hotbars: Hotbar[] = [];
@observable private _activeHotbarId!: string; @observable private _activeHotbarId!: string;

View File

@ -26,8 +26,6 @@ interface Dependencies extends BaseStoreDependencies {
} }
export class UserStore extends BaseStore<UserStoreModel> /* implements UserStoreFlatModel (when strict null is enabled) */ { export class UserStore extends BaseStore<UserStoreModel> /* implements UserStoreFlatModel (when strict null is enabled) */ {
readonly displayName = "UserStore";
constructor(protected readonly dependencies: Dependencies) { constructor(protected readonly dependencies: Dependencies) {
super(dependencies, { super(dependencies, {
configName: "lens-user-store", configName: "lens-user-store",

View File

@ -27,7 +27,6 @@ export interface WeblinkStoreModel {
} }
export class WeblinkStore extends BaseStore<WeblinkStoreModel> { export class WeblinkStore extends BaseStore<WeblinkStoreModel> {
readonly displayName = "WeblinkStore";
@observable weblinks: WeblinkData[] = []; @observable weblinks: WeblinkData[] = [];
constructor(deps: BaseStoreDependencies) { constructor(deps: BaseStoreDependencies) {

View File

@ -25,7 +25,6 @@ interface Dependencies extends BaseStoreDependencies {
} }
export class FileSystemProvisionerStore extends BaseStore<FSProvisionModel> { export class FileSystemProvisionerStore extends BaseStore<FSProvisionModel> {
readonly displayName = "FilesystemProvisionerStore";
readonly registeredExtensions = observable.map<LensExtensionId, string>(); readonly registeredExtensions = observable.map<LensExtensionId, string>();
constructor(protected readonly dependencies: Dependencies) { constructor(protected readonly dependencies: Dependencies) {

View File

@ -63,7 +63,6 @@ export abstract class ExtensionStore<T extends object> extends BaseStore<T> {
ExtensionStore.instances.delete(this); ExtensionStore.instances.delete(this);
} }
readonly displayName = "ExtensionStore<T>";
protected extension?: LensExtension; protected extension?: LensExtension;
loadExtension(extension: LensExtension) { loadExtension(extension: LensExtension) {

View File

@ -24,7 +24,6 @@ export interface IsEnabledExtensionDescriptor {
} }
export class ExtensionsStore extends BaseStore<LensExtensionsStoreModel> { export class ExtensionsStore extends BaseStore<LensExtensionsStoreModel> {
readonly displayName = "ExtensionsStore";
constructor(deps: BaseStoreDependencies) { constructor(deps: BaseStoreDependencies) {
super(deps, { super(deps, {
configName: "lens-extensions", configName: "lens-extensions",