Skip to content

Commit

Permalink
Should fix #530
Browse files Browse the repository at this point in the history
  • Loading branch information
ransome1 committed Oct 9, 2023
1 parent d00886f commit 655150b
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 231 deletions.
414 changes: 214 additions & 200 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/__tests__/__mock__/recurrence.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

2023-09-29 Line 1 rec:1d due:2023-09-30
2023-09-29 Line 1 rec:w due:2023-10-06
2023-09-29 Line 1 rec:2m due:2023-11-29
2023-09-29 Line 1 rec:+1d due:2023-10-01
2023-09-29 Line 1 rec:7w due:2023-11-17
2023-10-09 Line 1 rec:1d due:2023-10-10
2023-10-09 Line 1 rec:w due:2023-10-16
2023-10-09 Line 1 rec:2m due:2023-12-09
2023-10-09 Line 1 rec:+1d due:2023-10-11
2023-10-09 Line 1 rec:7w due:2023-11-27
2023-07-21 Line 1 due:2023-07-24 rec:+1b
2021-01-01 taxes are due in one year t:2022-03-30 due:2022-04-30 rec:+1y
2023-09-29 Water plants @home +quick due:2023-10-06 t:2023-09-26 rec:1w
2023-09-29 Line 1 rec:+1d t:2023-09-20 due:2023-09-30
2023-10-09 Water plants @home +quick due:2023-10-16 t:2023-10-06 rec:1w
2023-10-09 Line 1 rec:+1d t:2023-09-20 due:2023-10-10
2 changes: 1 addition & 1 deletion src/__tests__/__mock__/test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Line 1
Edited line
New line
2023-09-29 New line with creation date
2023-10-09 New line with creation date
New line with relative threshold date t:June 3rd, 2005
15 changes: 2 additions & 13 deletions src/main/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import createMenu from './modules/Menu';
import { createTray } from './modules/Tray';
import { Sorting, File, ConfigData } from './util';
import processDataRequest from './modules/ProcessDataRequest';
import handleTheme from './modules/Theme';

const userDataDirectory = path.join(app.getPath('userData'), 'userData' + app.getVersion());
if (!fs.existsSync(userDataDirectory)) fs.mkdirSync(userDataDirectory)
Expand Down Expand Up @@ -145,18 +146,6 @@ configStorage.onDidChange('tray', () => {
});
});

nativeTheme.on('updated', () => {
const shouldUseDarkColors = nativeTheme.shouldUseDarkColors;

configStorage.set('shouldUseDarkColors', shouldUseDarkColors);

mainWindow!.webContents.send('setShouldUseDarkColors', shouldUseDarkColors);

createTray().then(result => {
console.log('config.ts:', result);
}).catch(error => {
console.error('config.ts:', error);
});
});
nativeTheme.on('updated', handleTheme);

export { configStorage, filterStorage };
6 changes: 3 additions & 3 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import log from 'electron-log';
import createMenu from './modules/Menu';
import { resolveHtmlPath, getAssetPath, File } from './util';
import createFileWatcher from './modules/File/Watcher';
import { createTray } from './modules/Tray';
import createTray from './modules/Tray';
import './modules/Ipc';
import handleTheme from './modules/Theme';

const files: File[] = (configStorage.get('files') as File[]) || [];
const windowMaximized: boolean = configStorage.get('windowMaximized');
Expand Down Expand Up @@ -116,8 +117,7 @@ const createWindow = async() => {
});
}

const colorTheme = configStorage.get('colorTheme');
if(colorTheme) nativeTheme.themeSource = colorTheme;
handleTheme();

handleWindowSizeAndPosition();

Expand Down
6 changes: 0 additions & 6 deletions src/main/modules/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,6 @@ function createMenu(files: File[]) {
shell.openExternal('https://github.com/sponsors/ransome1');
},
},
{
label: 'Changelog',
click: () => {
shell.openExternal('https://github.com/ransome1/sleek/blob/master/CHANGELOG.md');
},
},
{
label: 'sleek on GitHub',
click: () => {
Expand Down
20 changes: 20 additions & 0 deletions src/main/modules/Theme.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { nativeTheme } from 'electron';
import { mainWindow } from '../main';
import createTray from './Tray';
import { configStorage } from '../config';

const handleTheme = () => {
const shouldUseDarkColors = nativeTheme.shouldUseDarkColors;

configStorage.set('shouldUseDarkColors', shouldUseDarkColors);

mainWindow!.webContents.send('setShouldUseDarkColors', shouldUseDarkColors);

createTray().then(result => {
console.log('config.ts:', result);
}).catch(error => {
console.error('config.ts:', error);
});
}

export default handleTheme;
2 changes: 1 addition & 1 deletion src/main/modules/Tray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ function createTray() {
}
}

export { createTray };
export default createTray;

0 comments on commit 655150b

Please sign in to comment.