From bfcf9482693ed569d0591581bc57979c68ed911f Mon Sep 17 00:00:00 2001 From: ransome1 Date: Tue, 12 Dec 2023 22:12:16 +0100 Subject: [PATCH] Added click event to tray --- .erb/configs/webpack.config.main.prod.ts | 2 +- flatpak/com.github.ransome1.sleek.appdata.xml | 2 +- package.json | 2 +- src/main/config.tsx | 4 ++-- src/main/{main.ts => main.tsx} | 2 +- src/main/modules/Tray.tsx | 5 ++++- 6 files changed, 10 insertions(+), 7 deletions(-) rename src/main/{main.ts => main.tsx} (99%) diff --git a/.erb/configs/webpack.config.main.prod.ts b/.erb/configs/webpack.config.main.prod.ts index e6857456..747c1513 100644 --- a/.erb/configs/webpack.config.main.prod.ts +++ b/.erb/configs/webpack.config.main.prod.ts @@ -23,7 +23,7 @@ const configuration: webpack.Configuration = { target: 'electron-main', entry: { - main: path.join(webpackPaths.srcMainPath, 'main.ts'), + main: path.join(webpackPaths.srcMainPath, 'main.tsx'), preload: path.join(webpackPaths.srcMainPath, 'preload.js'), }, diff --git a/flatpak/com.github.ransome1.sleek.appdata.xml b/flatpak/com.github.ransome1.sleek.appdata.xml index 407c1830..e897ebbc 100755 --- a/flatpak/com.github.ransome1.sleek.appdata.xml +++ b/flatpak/com.github.ransome1.sleek.appdata.xml @@ -9,7 +9,7 @@ Robin Ahle - + https://github.com/ransome1/sleek https://github.com/ransome1/sleek/issues diff --git a/package.json b/package.json index 30f24855..b34e16a2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sleek", "version": "2.0.3", - "main": "./src/main/main.ts", + "main": "./src/main/main.tsx", "scripts": { "build": "concurrently \"yarn run peggy\" \"yarn run build:main\" \"yarn run build:renderer\"", "build:dll": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.ts", diff --git a/src/main/config.tsx b/src/main/config.tsx index 7da2e110..8ca9e6cf 100644 --- a/src/main/config.tsx +++ b/src/main/config.tsx @@ -114,8 +114,8 @@ configStorage.onDidAnyChange((newValue, oldValue) => { }); configStorage.onDidChange('files', async (files: File[] | undefined) => { - if (files) { - mainWindow!.webContents.send('updateFiles', files); + if(files && mainWindow) { + mainWindow.webContents.send('updateFiles', files); } }); diff --git a/src/main/main.ts b/src/main/main.tsx similarity index 99% rename from src/main/main.ts rename to src/main/main.tsx index cfe788e3..cbf88bee 100644 --- a/src/main/main.ts +++ b/src/main/main.tsx @@ -151,7 +151,7 @@ const handleReadyToShow = async () => { try { if(files && Object.keys(files)?.length > 0) { const response = createFileWatcher(files); - console.log('main.ts:', response); + console.log(response); } } catch (error: any) { console.log(error); diff --git a/src/main/modules/Tray.tsx b/src/main/modules/Tray.tsx index c72d9997..ac59c3ff 100644 --- a/src/main/modules/Tray.tsx +++ b/src/main/modules/Tray.tsx @@ -1,5 +1,5 @@ import { app, Menu, Tray } from 'electron'; -import { handleCreateWindow, mainWindow } from '../main'; +import { handleCreateWindow } from '../main'; import { configStorage } from '../config'; import { getAssetPath, File } from '../util'; import { setFile } from './File/File'; @@ -52,6 +52,9 @@ function createTray() { tray = new Tray(getAssetPath(`icons/tray/${iconName}`)); tray.setToolTip('sleek'); tray.setContextMenu(menu); + tray.on('click', () => { + handleCreateWindow(); + }); } export { createTray };