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 syncDisposers: Disposer[] = [];
readonly displayName = this.params.configName;
readonly displayName = kebabCase(this.params.configName).toUpperCase();
protected constructor(
protected readonly dependencies: BaseStoreDependencies,
protected readonly params: BaseStoreParams<T>,
) {
makeObservable(this);
this.displayName = this.params.configName;
}
/**
* This must be called after the last child's constructor is finished (or just before it finishes)
*/
load() {
this.dependencies.logger.info(`[${kebabCase(this.displayName).toUpperCase()}]: LOADING ...`);
this.dependencies.logger.info(`[${this.displayName}]: LOADING ...`);
this.storeConfig = this.dependencies.getConfigurationFileModel({
projectName: "lens",
projectVersion: this.dependencies.storeMigrationVersion,
@ -71,7 +69,7 @@ export abstract class BaseStore<T extends object> {
}
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() {
@ -95,7 +93,7 @@ export abstract class BaseStore<T extends object> {
}
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
if (this.storeConfig) {
@ -116,14 +114,14 @@ export abstract class BaseStore<T extends object> {
if (ipcMain) {
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);
}));
}
if (ipcRenderer) {
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);
}));
}

View File

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

View File

@ -27,7 +27,6 @@ interface Dependencies extends BaseStoreDependencies {
}
export class HotbarStore extends BaseStore<HotbarStoreModel> {
readonly displayName = "HotbarStore";
@observable hotbars: Hotbar[] = [];
@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) */ {
readonly displayName = "UserStore";
constructor(protected readonly dependencies: Dependencies) {
super(dependencies, {
configName: "lens-user-store",

View File

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

View File

@ -25,7 +25,6 @@ interface Dependencies extends BaseStoreDependencies {
}
export class FileSystemProvisionerStore extends BaseStore<FSProvisionModel> {
readonly displayName = "FilesystemProvisionerStore";
readonly registeredExtensions = observable.map<LensExtensionId, string>();
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);
}
readonly displayName = "ExtensionStore<T>";
protected extension?: LensExtension;
loadExtension(extension: LensExtension) {

View File

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