Skip to content

Refactor/app config#260

Open
egalvis27 wants to merge 5 commits intomainfrom
refactor/app-config
Open

Refactor/app config#260
egalvis27 wants to merge 5 commits intomainfrom
refactor/app-config

Conversation

@egalvis27
Copy link

What is Changed / Added


Application settings management has been improved with the addition of reactive language and theme configuration. These settings now update dynamically throughout the application in real-time.

Why

This enhancement will enable us to standardize the onboarding experience to match the Windows implementation, as the two platforms currently differ in this regard.

@egalvis27 egalvis27 requested a review from AlexisMora February 26, 2026 19:35

for (const [key, value] of Object.entries(savedConfig)) {
ConfigStore.set(key, value);
ConfigStore.set(key as keyof AppStore, value as AppStore[keyof AppStore]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


ipcMain.on('set-config-key', (_, { key, value }) => {
setConfigKey(key, value);
setConfigKey({ key, value } as SetConfigKeyProps);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAme

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 9 to 18
export type StoredValues = keyof AppStore;

type SetConfigKeyProps = { key: 'preferedLanguage'; value: Language } | { key: 'preferedTheme'; value: ConfigTheme };

export type { SetConfigKeyProps };

export const getConfigKey = <T extends StoredValues>(key: T): AppStore[T] => {
return store.get(key);
return electronStore.get(key);
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would create a type file instead of having these in here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

import { Theme, ConfigTheme, ThemeData } from './theme.types';

export function getTheme(): ThemeData {
const configTheme = electronStore.get('preferedTheme') as ConfigTheme;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,27 @@
import { nativeTheme } from 'electron';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: I have created src/core folder for these types of functionalities regarding overall app behaviour

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

i18next.changeLanguage(lang);
dayjs.locale(DayJsLocales[lang as Language]);
window.electron.setConfigKey('preferedLanguage', lang);
window.electron.setConfigKey('preferedLanguage', lang as Language);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAme

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +9 to +39
@@ -25,16 +27,16 @@ export default function ThemePicker(): JSX.Element {

const refreshPreferedTheme = async () => {
const theme = await window.electron.getConfigKey('preferedTheme');
if (theme === '' || theme === null) {
if (!theme) {
setSelectedTheme(DEFAULT_THEME);
} else {
setSelectedTheme(theme as Theme);
setSelectedTheme(theme as ConfigTheme);
}
};

const updatePreferedTheme = (theme: string) => {
window.electron.toggleDarkMode(theme as Theme);
window.electron.setConfigKey('preferedTheme', theme);
window.electron.toggleDarkMode(theme as ConfigTheme);
window.electron.setConfigKey('preferedTheme', theme as ConfigTheme);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get rid of forcing the types like this with the as type assertion whenever possible

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 33 to 36
if (!lang) {
setSelectedLanguage(DEFAULT_LANGUAGE);
} else {
setSelectedLanguage(lang);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!lang) {
setSelectedLanguage(DEFAULT_LANGUAGE);
} else {
setSelectedLanguage(lang);
setSelectedLanguage(lang ?? DEFAULT_LANGUAGE);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +28 to +31
if (!theme) {
setSelectedTheme(DEFAULT_THEME);
} else {
setSelectedTheme(theme as Theme);
setSelectedTheme(theme);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!theme) {
setSelectedTheme(DEFAULT_THEME);
} else {
setSelectedTheme(theme as Theme);
setSelectedTheme(theme);
setSelectedTheme(theme ?? DEFAULT_THEME);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +3 to +6
/** All selectable theme values including 'system' */
export type ConfigTheme = (typeof themes)[number];

export const DEFAULT_THEME = 'system';
/** Resolved (applied) theme — never 'system' */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are this comments necessary? seems like they lack context

@egalvis27 egalvis27 requested a review from AlexisMora March 9, 2026 21:58
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
65.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants