mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feat-560] delay song details cache loading after user setup is done
added check if ElectronStore is null
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import ElectronStore from "electron-store";
|
||||
import fs from "fs-extra";
|
||||
import { InstallationLocationService } from "./installation-location.service";
|
||||
import { CustomError } from "shared/models/exceptions/custom-error.class";
|
||||
|
||||
export class ConfigurationService {
|
||||
private static instance: ConfigurationService;
|
||||
@@ -14,6 +15,7 @@ export class ConfigurationService {
|
||||
|
||||
private readonly locations: InstallationLocationService;
|
||||
|
||||
private contentPath: string;
|
||||
private store: ElectronStore;
|
||||
|
||||
private constructor() {
|
||||
@@ -29,6 +31,7 @@ export class ConfigurationService {
|
||||
return;
|
||||
}
|
||||
|
||||
this.contentPath = contentPath;
|
||||
this.store = new ElectronStore({
|
||||
cwd: contentPath,
|
||||
name: "config",
|
||||
@@ -37,15 +40,25 @@ export class ConfigurationService {
|
||||
});
|
||||
}
|
||||
|
||||
private checkStore(): void {
|
||||
// Can be null if config.cfg does not exist or corrupted
|
||||
if (!this.store) {
|
||||
throw CustomError.fromError(new Error(`Can't read config.cfg on ${this.contentPath}`));
|
||||
}
|
||||
}
|
||||
|
||||
public set(key: string, value: unknown): void {
|
||||
this.checkStore();
|
||||
this.store.set(key, value);
|
||||
}
|
||||
|
||||
public get<T>(key: string): T {
|
||||
this.checkStore();
|
||||
return this.store.get(key) as T;
|
||||
}
|
||||
|
||||
public delete(key: string): void {
|
||||
this.checkStore();
|
||||
this.store.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ export const AskInstallPathModal: ModalComponent<{ installPath: string }, {}> =
|
||||
<BsmButton
|
||||
onClick={selectInstallPath}
|
||||
className="shrink-1 whitespace-nowrap mr-2 px-2 font-bold italic text-sm rounded-md"
|
||||
text={"modals.ask-install-path.choose-folder"}
|
||||
text="modals.ask-install-path.choose-folder"
|
||||
withBar={false}
|
||||
/>
|
||||
</div>
|
||||
@@ -88,14 +88,14 @@ export const AskInstallPathModal: ModalComponent<{ installPath: string }, {}> =
|
||||
className="col-start-3 rounded-md text-center transition-all"
|
||||
onClick={onDefaultButtonPressed}
|
||||
withBar={false}
|
||||
text={"modals.ask-install-path.default"}
|
||||
text="modals.ask-install-path.default"
|
||||
/>
|
||||
<BsmButton
|
||||
typeColor="primary"
|
||||
className="col-start-4 z-0 px-1 rounded-md text-center transition-all"
|
||||
type="submit"
|
||||
withBar={false}
|
||||
text={"misc.confirm"}
|
||||
text="misc.confirm"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -33,6 +33,7 @@ export class SetupService {
|
||||
|
||||
public async check(): Promise<void> {
|
||||
try {
|
||||
// NOTE: for modal sequencing
|
||||
await this.checkInstallationPath();
|
||||
} catch (error) {
|
||||
logRenderError(error);
|
||||
@@ -57,7 +58,7 @@ export class SetupService {
|
||||
await lastValueFrom(this.steamDownloaderService.setInstallationFolder(modalResponse.data.installPath));
|
||||
|
||||
// Refresh the versions tab
|
||||
await this.versionManagerService.askInstalledVersions()
|
||||
await this.versionManagerService.askInstalledVersions();
|
||||
} catch (error) {
|
||||
logRenderError(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user