Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
Revert "Show error if OWML in sub-path of Mod Manager"
Browse files Browse the repository at this point in the history
This reverts commit 8c395a7.
  • Loading branch information
Raicuparta committed Jul 9, 2021
1 parent 59a8b8e commit b163ad9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
1 change: 0 additions & 1 deletion app/components/Settings/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const TextInput: FunctionComponent<Props> = ({
);
const handleSaveClick = () => {
onChange(text);
setText(value);
};

useEffect(() => {
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/static-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ export const settingsText = {
getSettingsError: (path: string) =>
`Error while getting settings file in ${path}: `,
setInvalidSettingsError: 'Trying to set invalid settings',
owmlChildOfManagerError:
"OWML can't be in a sub-path of the Mod Manager. Move OWML elsewhere.",
setInvalidOwmlSettingsError: 'Trying to set invalid OWML settings',
steamParamsWarning: {
message: 'Steam might show a warning before starting the game',
Expand Down
1 change: 1 addition & 0 deletions app/services/get-mod-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type ModDatabase = {
modManager: ModManager;
};

// eslint-disable-next-line import/prefer-default-export
export async function getModDatabase(
url: string,
owmlPath: string
Expand Down
31 changes: 9 additions & 22 deletions app/services/settings-manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import fs from 'fs-extra';
import { relative } from 'path';
import { remote } from 'electron';

import config from '../config.json';
Expand Down Expand Up @@ -27,30 +26,18 @@ export async function getSettings<TSettings>(path: string) {
}

export function writeSettings(settings: Settings) {
try {
if (!settings) {
throw new Error(settingsText.setInvalidSettingsError);
}

debugConsole.log('writing app settings');
if (!settings) {
throw new Error(settingsText.setInvalidSettingsError);
}

if (!relative('.', settings.owmlPath).startsWith('..')) {
throw new Error(settingsText.owmlChildOfManagerError);
}
debugConsole.log('writing app settings');

const constrainedSettings: Settings = {
...settings,
logToSocket: settings.closeOnPlay ? false : settings.logToSocket,
};
const constrainedSettings: Settings = {
...settings,
logToSocket: settings.closeOnPlay ? false : settings.logToSocket,
};

fs.writeJsonSync(getSettingsPath(), constrainedSettings);
} catch (error) {
remote.dialog.showMessageBox({
type: 'error',
title: remote.app.name,
message: error.message,
});
}
fs.writeJsonSync(getSettingsPath(), constrainedSettings);
}

export function writeOwmlSettings(path: string, settings: OwmlSettings) {
Expand Down

0 comments on commit b163ad9

Please sign in to comment.