Skip to content

Commit

Permalink
Merge branch 'master' into update-default-data
Browse files Browse the repository at this point in the history
  • Loading branch information
frankkopp authored Nov 17, 2024
2 parents 4a82243 + 6d332ce commit e290030
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
7 changes: 7 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ function initializeApp() {

mainWindow.center();

if (
(settings.get('mainSettings.configDownloadUrl') as string) ===
'https://cdn.flybywiresim.com/installer/config/production.json'
) {
settings.set('mainSettings.configDownloadUrl', packageInfo.configUrls.production);
}

if (import.meta.env.DEV) {
mainWindow.webContents.openDevTools();
}
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/components/SettingsSection/Developer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC, useCallback, useEffect, useState } from 'react';
import { useSetting } from 'renderer/rendererSettings';
import { Toggle } from 'renderer/components/Toggle';
import * as packageInfo from '../../../../package.json';

const SettingsItem: FC<{ name: string }> = ({ name, children }) => (
<div className="flex flex-row items-center justify-between py-3.5">
Expand Down Expand Up @@ -44,6 +45,12 @@ export const DeveloperSettings: React.FC = () => {
onBlur={() => validateUrl()}
size={50}
/>
<input
className="ml-2"
type="button"
value="Reset to default"
onClick={() => setConfigDownloadUrl(packageInfo.configUrls.production)}
/>
</div>
</SettingsItem>
<SettingsItem name="Force Use Local Configuration">
Expand Down
44 changes: 24 additions & 20 deletions src/renderer/utils/IncompatibleAddOnsCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,34 @@ export class IncompatibleAddOnsCheck {
const dirEntries = fs.readdirSync(filePath);

if (dirEntries.includes(manifestFileName)) {
const manifest = JSON.parse(fs.readFileSync(path.join(filePath, manifestFileName), 'utf8'));
try {
const manifest = JSON.parse(fs.readFileSync(path.join(filePath, manifestFileName), 'utf8'));

for (const item of addon.incompatibleAddons) {
// This checks the configuration item properties (if set) against the manifest.json file
// entry property values. If all properties match, the add-on is considered incompatible.
// packageVersion syntax follows: https://www.npmjs.com/package/semver
// Future improvement would be to allow for regular expressions in the configuration item.
const titleMatches = !item.title || manifest.title === item.title;
const creatorMatches = !item.creator || manifest.creator === item.creator;
const packageVersionTargeted =
!item.packageVersion || semverSatisfies(manifest.package_version, item.packageVersion);
for (const item of addon.incompatibleAddons) {
// This checks the configuration item properties (if set) against the manifest.json file
// entry property values. If all properties match, the add-on is considered incompatible.
// packageVersion syntax follows: https://www.npmjs.com/package/semver
// Future improvement would be to allow for regular expressions in the configuration item.
const titleMatches = !item.title || manifest.title === item.title;
const creatorMatches = !item.creator || manifest.creator === item.creator;
const packageVersionTargeted =
!item.packageVersion || semverSatisfies(manifest.package_version, item.packageVersion);

if (titleMatches && creatorMatches && packageVersionTargeted) {
// Also write this to the log as this info might be useful for support.
console.log(`Incompatible Add-On found: ${manifest.title}: ${item.description}`);
if (titleMatches && creatorMatches && packageVersionTargeted) {
// Also write this to the log as this info might be useful for support.
console.log(`Incompatible Add-On found: ${manifest.title}: ${item.description}`);

incompatibleAddons.push({
title: item.title,
creator: item.creator,
packageVersion: item.packageVersion,
folder: entry,
description: item.description,
});
incompatibleAddons.push({
title: item.title,
creator: item.creator,
packageVersion: item.packageVersion,
folder: entry,
description: item.description,
});
}
}
} catch (e) {
console.warn(`Failed to read or parse manifest.json in ${filePath}:`, e.message);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/utils/InstallerConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ export class InstallerConfiguration {
}

private static async fetchConfigurationFromCdn(): Promise<Configuration> {
const url = settings.get('mainSettings.configDownloadUrl') as string;
const url = `${settings.get('mainSettings.configDownloadUrl') as string}?cache-killer=${Math.random()}`;

console.log('Obtaining configuration from CDN (%s)', url);
return await fetch(url)
.then((res) => res.blob())
Expand Down

0 comments on commit e290030

Please sign in to comment.