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

fix: update settings in all open windows #1376

Merged
merged 5 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,39 @@ export interface PMOperationOptions {
dir: string;
packageManager: IPackageManager;
}

export enum GlobalSetting {
acceleratorsToBlock = 'acceleratorsToBlock',
channelsToShow = 'channelsToShow',
electronMirror = 'electronMirror',
environmentVariables = 'environmentVariables',
executionFlags = 'executionFlags',
fontFamily = 'fontFamily',
fontSize = 'fontSize',
gitHubAvatarUrl = 'gitHubAvatarUrl',
gitHubLogin = 'gitHubLogin',
gitHubName = 'gitHubName',
gitHubToken = 'gitHubToken',
hasShownTour = 'hasShownTour',
isClearingConsoleOnRun = 'isClearingConsoleOnRun',
isEnablingElectronLogging = 'isEnablingElectronLogging',
isKeepingUserDataDirs = 'isKeepingUserDataDirs',
isPublishingGistAsRevision = 'isPublishingGistAsRevision',
isUsingSystemTheme = 'isUsingSystemTheme',
knownVersion = 'known-electron-versions',
localVersion = 'local-electron-versions',
packageAuthor = 'packageAuthor',
packageManager = 'packageManager',
showObsoleteVersions = 'showObsoleteVersions',
showUndownloadedVersions = 'showUndownloadedVersions',
theme = 'theme',
}

export type GlobalSettingKey = keyof typeof GlobalSetting;

export enum WindowSpecificSetting {
gitHubPublishAsPublic = 'gitHubPublishAsPublic',
version = 'version',
}

export type WindowSpecificSettingKey = keyof typeof WindowSpecificSetting;
23 changes: 15 additions & 8 deletions src/renderer/components/settings-execution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ import {
} from '@blueprintjs/core';
import { observer } from 'mobx-react';

import { IPackageManager } from '../../interfaces';
import {
GlobalSetting,
GlobalSettingKey,
IPackageManager,
} from '../../interfaces';
import { AppState } from '../state';

export enum SettingItemType {
EnvVars = 'environmentVariables',
Flags = 'executionFlags',
}
/**
* @TODO make this a proper enum again once we update Typescript
*/
export const SettingItemType = {
EnvVars: GlobalSetting.environmentVariables,
Flags: GlobalSetting.executionFlags,
} as const;
dsanders11 marked this conversation as resolved.
Show resolved Hide resolved

interface ExecutionSettingsProps {
appState: AppState;
Expand Down Expand Up @@ -119,7 +126,7 @@ export const ExecutionSettings = observer(
*/
public handleSettingsItemChange(
event: React.ChangeEvent<HTMLInputElement>,
type: SettingItemType,
type: GlobalSettingKey,
) {
const { name, value } = event.currentTarget;

Expand All @@ -136,7 +143,7 @@ export const ExecutionSettings = observer(
*
* @param {SettingItemType} type
*/
private addNewSettingsItem(type: SettingItemType) {
private addNewSettingsItem(type: GlobalSettingKey) {
const array = Object.entries(this.state[type]);

this.setState((prevState) => ({
Expand All @@ -160,7 +167,7 @@ export const ExecutionSettings = observer(
appState.packageManager = value as IPackageManager;
};

public renderDeleteItem(idx: string, type: SettingItemType): JSX.Element {
public renderDeleteItem(idx: string, type: GlobalSettingKey): JSX.Element {
const updated = this.state[type];

const removeFn = () => {
Expand Down
Loading