Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: read config json from documents dir #478

Merged
merged 15 commits into from
Oct 14, 2024
2 changes: 2 additions & 0 deletions src/renderer/components/AddonSection/MyInstall/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const MyInstall: FC<MyInstallProps> = ({ addon }) => {
return Directories.inInstallPackage(addon, def.location.path);
case 'packageCache':
return Directories.inPackageCache(addon, def.location.path);
case 'documents':
return Directories.inDocumentsFolder(def.location.path);
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/LocalApiConfigEditUI/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { PromptModal, useModals } from '../Modal';
import { Button, ButtonType } from '../Button';
import fs from 'fs';
import path from 'path';
import { Directories } from 'renderer/utils/Directories';
import { Toggle } from '../Toggle';
import { app } from '@electron/remote';

const SIMBRIDGE_DIRECTORY = 'flybywire-externaltools-simbridge';
const SIMBRIDGE_DIRECTORY = '/FlyByWireSim/Simbridge';

interface LocalApiConfiguration {
server: {
Expand Down Expand Up @@ -37,7 +37,7 @@ const localApiDefaultConfiguration: LocalApiConfiguration = {

class LocalApiConfigurationHandler {
private static get simbridgeDirectory(): string {
return path.join(Directories.inInstallLocation(SIMBRIDGE_DIRECTORY));
return path.join(app.getPath('documents'), SIMBRIDGE_DIRECTORY);
}

private static get simbridgeConfigPath(): string {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ export const defaultConfiguration: Configuration = {
directories: [
{
location: {
in: 'package',
path: 'resources',
in: 'documents',
path: 'FlyByWireSim/Simbridge/resources',
},
title: 'Resources',
},
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/utils/Directories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,8 @@ export class Directories {
return false;
}
}

static inDocumentsFolder(targetDir: string): string {
return path.join(app.getPath('documents'), this.sanitize(targetDir));
}
}
4 changes: 2 additions & 2 deletions src/renderer/utils/InstallerConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ExternalLink {

export interface DirectoryDefinition {
location: {
in: 'community' | 'packageCache' | 'package';
in: 'community' | 'packageCache' | 'package' | 'documents';
path: string;
};
}
Expand Down Expand Up @@ -354,7 +354,7 @@ export interface Configuration {

export class InstallerConfiguration {
static async obtain(): Promise<Configuration> {
return this.fetchConfigurationFromCdn()
return this.loadConfigurationFromLocalStorage()
Saschl marked this conversation as resolved.
Show resolved Hide resolved
.then((config) => {
if (this.isConfigurationValid(config)) {
console.log('Configuration from CDN is valid');
Expand Down
Loading