Skip to content
Snippets Groups Projects
Commit 2c20a169 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[dome] initialize theme wrt global settings

parent 7d281d73
No related branches found
No related tags found
No related merge requests found
...@@ -199,6 +199,11 @@ function windowSyncSettings(event: IpcMainEvent) { ...@@ -199,6 +199,11 @@ function windowSyncSettings(event: IpcMainEvent) {
ipcMain.on('dome.ipc.settings.sync', windowSyncSettings); ipcMain.on('dome.ipc.settings.sync', windowSyncSettings);
function applyThemeSettings(settings: Store) {
const theme = settings['dome-color-theme'];
if (typeof (theme) === 'string') setNativeTheme(theme);
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- Patching Settings // --- Patching Settings
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -234,8 +239,7 @@ function applyStorageSettings(event: IpcMainEvent, args: Patch[]) { ...@@ -234,8 +239,7 @@ function applyStorageSettings(event: IpcMainEvent, args: Patch[]) {
function applyGlobalSettings(event: IpcMainEvent, args: Patch[]) { function applyGlobalSettings(event: IpcMainEvent, args: Patch[]) {
const settings: Store = obtainGlobalSettings(); const settings: Store = obtainGlobalSettings();
applyPatches(settings, args); applyPatches(settings, args);
const theme = settings['dome-color-theme']; applyThemeSettings(settings);
if (typeof (theme) === 'string') setNativeTheme(theme);
BrowserWindow.getAllWindows().forEach((w: BrowserWindow) => { BrowserWindow.getAllWindows().forEach((w: BrowserWindow) => {
const contents = w.webContents; const contents = w.webContents;
if (contents.id !== event.sender.id) { if (contents.id !== event.sender.id) {
...@@ -477,6 +481,12 @@ function createPrimaryWindow() { ...@@ -477,6 +481,12 @@ function createPrimaryWindow() {
const cwd = process.cwd(); const cwd = process.cwd();
const wdir = cwd === '/' ? app.getPath('home') : cwd; const wdir = cwd === '/' ? app.getPath('home') : cwd;
const argv = stripElectronArgv(process.argv); const argv = stripElectronArgv(process.argv);
// Initialize Theme
const globals = obtainGlobalSettings();
applyThemeSettings(globals);
// Create Window
createBrowserWindow({ title: appName }, argv, wdir); createBrowserWindow({ title: appName }, argv, wdir);
} }
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
// Enable live-editing in React: // Enable live-editing in React:
import 'react-hot-loader/patch' ; import 'react-hot-loader/patch' ;
import React from 'react' ; import React from 'react' ;
import { ipcRenderer } from 'electron';
import { import {
setApplicationWindow, setApplicationWindow,
setPreferencesWindow, setPreferencesWindow,
...@@ -59,9 +58,6 @@ import Preferences from './Preferences' ; ...@@ -59,9 +58,6 @@ import Preferences from './Preferences' ;
// Define the application main components for each window: // Define the application main components for each window:
setApplicationWindow(Application); setApplicationWindow(Application);
setPreferencesWindow(Preferences); setPreferencesWindow(Preferences);
ipcRenderer.send('dome.ipc.settings.window', []);
ipcRenderer.send('dome.ipc.settings.global', []);
ipcRenderer.send('dome.ipc.settings.storage', []);
// Mark the main application reloadable and enable live updates: // Mark the main application reloadable and enable live updates:
module.hot && isApplicationWindow() && module.hot && isApplicationWindow() &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment