Skip to content

Commit 2c2c7c1

Browse files
committed
Bump version to 1.1.7 and enhance notification features
1 parent d50cbd0 commit 2c2c7c1

File tree

9 files changed

+80
-214
lines changed

9 files changed

+80
-214
lines changed

assets/icon.png

34.3 KB
Loading

developer-options.html

Lines changed: 0 additions & 171 deletions
This file was deleted.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ <h2 class="modal-h2">About</h2>
8989
<p id="appVersion">Version: </p>
9090
<p id="electronVersion">Electron Version: </p>
9191
<button class="about-button" onclick="checkForUpdates()">Check for Updates</button>
92-
<button class="about-button" id="open-dev-options">Developer Options</button>
92+
<button class="about-button" id="open-dev-tools" onclick="window.API.openDevTools()">Open DevTools</button>
9393
</div>
9494
</div>
9595
</div>

index.js

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const { app, BrowserWindow, Menu, ipcMain } = require('electron');
1+
const { app, BrowserWindow, Tray, Menu, ipcMain, Notification } = require('electron');
2+
const path = require('path');
23

34
let mainWindow;
4-
let devWindow;
5+
let tray = null;
56

67
app.on('ready', () => {
78
mainWindow = new BrowserWindow({
@@ -29,38 +30,64 @@ app.on('ready', () => {
2930
mainWindow.loadFile('index.html');
3031

3132
mainWindow.on('closed', () => {
32-
app.quit();
33+
app.quit();
3334
});
3435

35-
ipcMain.on('open-dev-window', () => {
36-
createDevWindow();
36+
ipcMain.on('show-notification', (event, title, body) => {
37+
showNotification(title, body);
3738
});
39+
40+
ipcMain.on('open-dev-tools', () => {
41+
if (mainWindow) {
42+
mainWindow.webContents.openDevTools();
43+
}
44+
});
45+
46+
tray = new Tray(path.join(__dirname, 'assets/icon.png'));
47+
const contextMenu = Menu.buildFromTemplate([
48+
{
49+
label: 'Check for Updates', click: () => {
50+
console.log("Check for Updates menu item clicked"); // Add this line
51+
if (mainWindow) {
52+
mainWindow.webContents.send('check-for-updates'); // Send to renderer
53+
}
54+
}
55+
},
56+
{ type: 'separator' },
57+
{ label: 'Quit', click: () => app.quit() }
58+
]);
59+
tray.setToolTip('Iota\'s Notepad');
60+
tray.setContextMenu(contextMenu);
3861
});
3962

4063
app.on('window-all-closed', () => {
41-
if (process.platform !== 'darwin') app.quit();
64+
if (process.platform !== 'darwin') app.quit();
4265
});
4366

4467
if (require('electron-squirrel-startup')) app.quit();
4568

46-
function createDevWindow() {
47-
if (devWindow) {
48-
devWindow.focus();
49-
return;
50-
}
69+
function showNotification(title, body) {
70+
if (Notification.isSupported()) {
71+
let iconPath;
72+
iconPath = path.join(__dirname, 'assets', 'icon.png');
5173

52-
devWindow = new BrowserWindow({
53-
width: 800,
54-
height: 600,
55-
webPreferences: {
56-
nodeIntegration: true,
57-
},
58-
title: "Iota's Notepad - Developer Options"
59-
});
74+
const notification = new Notification({
75+
title: title,
76+
body: body,
77+
icon: iconPath,
78+
});
6079

61-
devWindow.loadFile('developer-options.html');
80+
notification.on('click', () => {
81+
console.log('Notification clicked');
82+
if (mainWindow) {
83+
if (mainWindow.isMinimized()) mainWindow.restore();
84+
mainWindow.focus();
85+
}
86+
});
6287

63-
devWindow.on('closed', () => {
64-
devWindow = null;
65-
});
88+
notification.show();
89+
} else {
90+
console.log('Notifications are not supported on this system.');
91+
}
6692
}
93+

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iotas-notepad",
3-
"version": "1.1.6",
3+
"version": "1.1.7",
44
"main": "index.js",
55
"scripts": {
66
"electron": "electron .",

preload.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const { contextBridge, ipcRenderer } = require('electron');
22

3-
// Expose only specific APIs to the renderer
4-
contextBridge.exposeInMainWorld('electron', {
5-
openDevWindow: () => ipcRenderer.send('open-dev-window'),
6-
});
7-
3+
contextBridge.exposeInMainWorld('API', {
4+
sendNotification: (title, body) => ipcRenderer.send('show-notification', title, body),
5+
openDevTools: () => ipcRenderer.send('open-dev-tools'),
6+
on: (channel, func) => ipcRenderer.on(channel, func),
7+
send: (channel, ...args) => ipcRenderer.send(channel, ...args),
8+
removeListener: (channel, func) => ipcRenderer.removeListener(channel, func)
9+
});

src/globals.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
--note-list-margin: 5px;
7474
--note-list-item-margin-right: 3px;
7575
--note-list-item-padding: 10px;
76-
--note-list-item-border: 1px solid var(--color-border);
76+
--note-list-item-border: 1px solid transparent;
7777
--note-list-item-border-selected: 1px solid var(--color-border);
7878
--note-list-item-cursor: pointer;
7979
--note-list-item-position: relative;

0 commit comments

Comments
 (0)