Skip to content

Commit

Permalink
Finish addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pecanoro committed Dec 19, 2022
1 parent 4e31474 commit e015a03
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
4 changes: 0 additions & 4 deletions desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,6 @@ const mainWindow = (() => {
}

ipcMain.on(ELECTRON_EVENTS.LOCALE_UPDATED, (event, updatedLocale) => {
if (preferredLocale === updatedLocale) {
return;
}

// Store the old locale so we can hide/remove these items after adding/showing the new ones.
const outdatedLocale = preferredLocale;
preferredLocale = updatedLocale;
Expand Down
15 changes: 3 additions & 12 deletions src/libs/Localize/LocaleListener/index.desktop.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import ELECTRON_EVENTS from '../../../../desktop/ELECTRON_EVENTS';
import BaseLocaleListener from './BaseLocaleListener';

const connect = (callback) => {
BaseLocaleListener.connect((val) => {
callback(val);

// Send the updated locale to the Electron main process
window.electron.send(ELECTRON_EVENTS.LOCALE_UPDATED, val);
});
};
const connect = () => {
// Send the updated locale to the Electron main process
BaseLocaleListener.connect(val => window.electron.send(ELECTRON_EVENTS.LOCALE_UPDATED, val));
};

const LocaleListener = {
listenForLocaleChanges,
export default {
connect,
};

export default LocaleListener;
10 changes: 2 additions & 8 deletions src/libs/Localize/LocaleListener/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import BaseLocaleListener from './BaseLocaleListener';

const listenForLocaleChanges = () => {
BaseLocaleListener.connect(() => {});
export default {
connect: BaseLocaleListener.connect,
};

const LocaleListener = {
listenForLocaleChanges,
};

export default LocaleListener;
2 changes: 1 addition & 1 deletion src/libs/Localize/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import LocaleListener from './LocaleListener';
import BaseLocaleListener from './LocaleListener/BaseLocaleListener';

// Listener when an update in Onyx happens so we use the updated locale when translating/localizing items.
LocaleListener.listenForLocaleChanges();
LocaleListener.connect();

/**
* Return translated string for given locale and phrase
Expand Down

0 comments on commit e015a03

Please sign in to comment.