Skip to content

Commit 794dee1

Browse files
committed
no tray, use badge
1 parent c1baabc commit 794dee1

File tree

11 files changed

+45
-123
lines changed

11 files changed

+45
-123
lines changed

clock.icns

42.4 KB
Binary file not shown.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"package": "electron-forge package",
1010
"make": "electron-forge make",
1111
"publish": "electron-forge publish",
12-
"lint": "eslint --ext .ts,.tsx ."
12+
"lint": "tsc --noEmit && eslint --ext .ts,.tsx ."
1313
},
1414
"keywords": [],
1515
"author": {
@@ -46,7 +46,9 @@
4646
}
4747
}
4848
],
49-
"packagerConfig": {},
49+
"packagerConfig": {
50+
"icon": "clock.icns"
51+
},
5052
"makers": [
5153
{
5254
"name": "@electron-forge/maker-squirrel",
@@ -102,7 +104,6 @@
102104
"@typescript-eslint/eslint-plugin": "^4.0.1",
103105
"@typescript-eslint/parser": "^4.0.1",
104106
"@vercel/webpack-asset-relocator-loader": "1.7.0",
105-
"copy-webpack-plugin": "^9.0.1",
106107
"css-loader": "^6.0.0",
107108
"electron": "15.1.0",
108109
"eslint": "^7.6.0",

src/main/assets/tray-idle.png

-441 Bytes
Binary file not shown.

src/main/assets/tray-idle@2x.png

-984 Bytes
Binary file not shown.

src/main/assets/tray-working.png

-644 Bytes
Binary file not shown.

src/main/assets/tray-working@2x.png

-1.48 KB
Binary file not shown.

src/main/badge.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { parseEntries } from '../shared/entries';
2+
import { parseTicket } from '../shared/tickets';
3+
import { AppError } from '../shared/errors';
4+
import { App } from '../shared/types';
5+
6+
const getText = (entries: string): string => {
7+
try {
8+
const parsed = parseEntries(entries);
9+
const lastEntry = parsed[parsed.length - 1];
10+
if (lastEntry) {
11+
const ticket = parseTicket(lastEntry.description);
12+
if (ticket !== '') {
13+
return ticket;
14+
}
15+
}
16+
} catch (e) {
17+
if (e instanceof AppError) {
18+
// No need to warn user here.
19+
} else {
20+
throw e;
21+
}
22+
}
23+
return '';
24+
};
25+
26+
export const initBadge = (app: App): void => {
27+
const onEntriesUpdate = (entries: string | undefined) => {
28+
const text = getText(entries || '');
29+
app.electronApp.dock.setBadge(text);
30+
};
31+
32+
app.store.onDidChange('entries', onEntriesUpdate);
33+
onEntriesUpdate(app.store.get('entries'));
34+
};

src/main/index.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { app as electronApp, BrowserWindow, dialog } from 'electron';
2-
import { createTray } from './tray';
32
import { registerShortcuts } from './shortcuts';
43
import { connectStore } from './store';
54
import { app } from './app';
65
import { AppError } from '../shared/errors';
6+
import { parseEntries } from '../shared/entries';
7+
import { parseTicket } from '../shared/tickets';
8+
import { initBadge } from './badge';
79
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
810

911
// From the boilerplate: Handle creating/removing shortcuts on Windows when
@@ -28,7 +30,6 @@ electronApp.on('ready', () => {
2830
nodeIntegration: true,
2931
contextIsolation: false,
3032
},
31-
skipTaskbar: true,
3233
});
3334

3435
app.window
@@ -42,10 +43,6 @@ electronApp.on('ready', () => {
4243
}
4344
});
4445

45-
app.window.on('blur', () => {
46-
app.electronApp.hide();
47-
});
48-
4946
connectStore(app);
5047
});
5148

@@ -55,12 +52,9 @@ electronApp.on('before-quit', () => {
5552

5653
electronApp.whenReady().then(() => {
5754
registerShortcuts(app);
58-
createTray(app);
55+
initBadge(app);
5956
});
6057

6158
electronApp.on('window-all-closed', () => {
6259
// Empty handler is required to disable auto-exit.
6360
});
64-
65-
// Electron.BrowserWindowConstructorOptions.skipTaskbar does not work on Mac.
66-
electronApp.dock.hide();

src/main/tray.ts

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

webpack.main.config.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
2-
const CopyPlugin = require('copy-webpack-plugin');
3-
41
module.exports = {
52
target: 'electron-main',
63
/**
@@ -15,9 +12,4 @@ module.exports = {
1512
resolve: {
1613
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
1714
},
18-
plugins: [
19-
new CopyPlugin({
20-
patterns: [{ from: 'src/main/assets', to: 'assets' }],
21-
}),
22-
],
2315
};

yarn.lock

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,19 +1747,6 @@ cookie@0.4.0:
17471747
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
17481748
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==
17491749

1750-
copy-webpack-plugin@^9.0.1:
1751-
version "9.0.1"
1752-
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-9.0.1.tgz#b71d21991599f61a4ee00ba79087b8ba279bbb59"
1753-
integrity sha512-14gHKKdYIxF84jCEgPgYXCPpldbwpxxLbCmA7LReY7gvbaT555DgeBWBgBZM116tv/fO6RRJrsivBqRyRlukhw==
1754-
dependencies:
1755-
fast-glob "^3.2.5"
1756-
glob-parent "^6.0.0"
1757-
globby "^11.0.3"
1758-
normalize-path "^3.0.0"
1759-
p-limit "^3.1.0"
1760-
schema-utils "^3.0.0"
1761-
serialize-javascript "^6.0.0"
1762-
17631750
core-js@^3.6.5:
17641751
version "3.18.1"
17651752
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.18.1.tgz#289d4be2ce0085d40fc1244c0b1a54c00454622f"
@@ -2728,7 +2715,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
27282715
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
27292716
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
27302717

2731-
fast-glob@^3.1.1, fast-glob@^3.2.5, fast-glob@^3.2.7:
2718+
fast-glob@^3.1.1, fast-glob@^3.2.7:
27322719
version "3.2.7"
27332720
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1"
27342721
integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==
@@ -3116,13 +3103,6 @@ glob-parent@^5.1.2, glob-parent@~5.1.2:
31163103
dependencies:
31173104
is-glob "^4.0.1"
31183105

3119-
glob-parent@^6.0.0:
3120-
version "6.0.2"
3121-
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3"
3122-
integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==
3123-
dependencies:
3124-
is-glob "^4.0.3"
3125-
31263106
glob-to-regexp@^0.4.1:
31273107
version "0.4.1"
31283108
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
@@ -3724,7 +3704,7 @@ is-fullwidth-code-point@^3.0.0:
37243704
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
37253705
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
37263706

3727-
is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1:
3707+
is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1:
37283708
version "4.0.3"
37293709
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
37303710
integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
@@ -5720,7 +5700,7 @@ schema-utils@2.7.0:
57205700
ajv "^6.12.2"
57215701
ajv-keywords "^3.4.1"
57225702

5723-
schema-utils@^3.0.0, schema-utils@^3.1.0, schema-utils@^3.1.1:
5703+
schema-utils@^3.1.0, schema-utils@^3.1.1:
57245704
version "3.1.1"
57255705
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281"
57265706
integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==

0 commit comments

Comments
 (0)