Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 47d30bb

Browse files
authored
Merge pull request #23 from Yadro/fixes-v1
Able to adjust the text size and other fixes
2 parents d3c19f5 + b929040 commit 47d30bb

File tree

10 files changed

+973
-815
lines changed

10 files changed

+973
-815
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ GA_UACODE=UA-XXXXXXXXX-X
44
# But dotenv-webpack plugin will replace it by string and parse by Terser will fail.
55
# NODE_DEBUG=request # debug requests in analytics
66
# DEBUG_PROD=true
7+
# FORCE_ENABLE_ANALYTICS=true
8+
# FORCE_ENABLE_SENTRY=true

package.json

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@
164164
"@types/history": "4.7.6",
165165
"@types/jest": "^26.0.24",
166166
"@types/node": "14.14.10",
167-
"@types/react": "^16.9.44",
168-
"@types/react-dom": "^16.9.9",
167+
"@types/react": "18.0.14",
168+
"@types/react-dom": "17.0.11",
169169
"@types/react-router-dom": "^5.1.6",
170+
"@types/universal-analytics": "0.4.5",
170171
"@types/uuid": "^8.3.3",
171172
"@types/webpack-env": "^1.15.2",
172173
"@typescript-eslint/eslint-plugin": "^4.8.1",
@@ -185,11 +186,11 @@
185186
"css-minimizer-webpack-plugin": "^2.0.0",
186187
"detect-port": "^1.3.0",
187188
"dotenv-webpack": "^7.0.3",
188-
"electron": "^12.0.2",
189-
"electron-builder": "^22.11.7",
190-
"electron-devtools-installer": "git+https://github.com/MarshallOfSound/electron-devtools-installer.git",
191-
"electron-notarize": "^1.0.0",
192-
"electron-rebuild": "^2.3.2",
189+
"electron": "19.0.0",
190+
"electron-builder": "23.1.0",
191+
"electron-devtools-installer": "3.2.0",
192+
"electron-notarize": "1.2.1",
193+
"electron-rebuild": "3.2.7",
193194
"eslint": "^7.5.0",
194195
"eslint-config-airbnb": "^18.2.0",
195196
"eslint-config-airbnb-typescript": "^12.0.0",
@@ -229,15 +230,15 @@
229230
},
230231
"dependencies": {
231232
"@ant-design/colors": "6.0.0",
232-
"@ant-design/icons": "4.6.2",
233+
"@ant-design/icons": "4.7.0",
233234
"@sentry/electron": "2.5.0",
234-
"antd": "4.17.2",
235+
"antd": "4.21.3",
235236
"caniuse-lite": "1.0.30001214",
236237
"clsx": "^1.1.1",
237238
"date-fns": "2.20.1",
238-
"electron-debug": "^3.1.0",
239-
"electron-log": "^4.2.4",
240-
"electron-updater": "^4.3.4",
239+
"electron-debug": "3.2.0",
240+
"electron-log": "4.4.8",
241+
"electron-updater": "5.0.5",
241242
"electron-windows-badge": "1.1.0",
242243
"history": "^5.0.0",
243244
"less": "4.1.1",
@@ -246,24 +247,21 @@
246247
"mobx": "6.1.8",
247248
"mobx-react": "7.1.0",
248249
"moment": "2.29.1",
249-
"react": "^17.0.1",
250-
"react-dom": "^17.0.1",
250+
"react": "18.2.0",
251+
"react-dom": "18.2.0",
251252
"react-hook-media-query": "^1.0.5",
252253
"react-jss": "^10.6.0",
253254
"react-router-dom": "^5.2.0",
254255
"regenerator-runtime": "^0.13.5",
255256
"source-map-support": "^0.5.19",
256-
"universal-analytics": "^0.4.23",
257+
"universal-analytics": "0.5.3",
257258
"uuid": "^8.3.2"
258259
},
259260
"devEngines": {
260261
"node": ">=14.x",
261262
"npm": ">=6.x",
262263
"yarn": ">=1.21.3"
263264
},
264-
"collective": {
265-
"url": "https://opencollective.com/electron-react-boilerplate-594"
266-
},
267265
"browserslist": [],
268266
"prettier": {
269267
"overrides": [

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
55
<title>Time Tracker</title>

src/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import React from 'react';
2+
3+
// Due to issue with antd, we need to use old react api
24
import { render } from 'react-dom';
5+
// FIXME: import { createRoot } from 'react-dom/client';
6+
37
import dotenv from 'dotenv';
48

59
import App from './App';
@@ -11,3 +15,4 @@ dotenv.config();
1115
initSentry();
1216

1317
render(<App />, document.getElementById('root'));
18+
// createRoot(document.getElementById('root')).render(<App />);

src/menu.ts

Lines changed: 33 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
app,
32
Menu,
43
shell,
54
BrowserWindow,
@@ -11,6 +10,9 @@ interface DarwinMenuItemConstructorOptions extends MenuItemConstructorOptions {
1110
submenu?: DarwinMenuItemConstructorOptions[] | Menu;
1211
}
1312

13+
const isDev =
14+
process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true';
15+
1416
export default class MenuBuilder {
1517
mainWindow: BrowserWindow;
1618

@@ -27,10 +29,8 @@ export default class MenuBuilder {
2729
}
2830

2931
const template =
30-
process.platform === 'darwin'
31-
? this.buildDarwinTemplate()
32-
: [];
33-
// : this.buildDefaultTemplate(); // Disable menu for Win and Linux
32+
process.platform === 'darwin' ? this.buildDarwinTemplate() : [];
33+
// : this.buildDefaultTemplate(); // Disable menu for Win and Linux
3434

3535
const menu = Menu.buildFromTemplate(template);
3636
Menu.setApplicationMenu(menu);
@@ -54,143 +54,45 @@ export default class MenuBuilder {
5454
}
5555

5656
buildDarwinTemplate(): MenuItemConstructorOptions[] {
57-
const subMenuAbout: DarwinMenuItemConstructorOptions = {
58-
label: 'Electron',
57+
const none = [] as any;
58+
const subMenuApp: DarwinMenuItemConstructorOptions = {
59+
label: 'TimeTracker',
5960
submenu: [
60-
{
61-
label: 'About ElectronReact',
62-
selector: 'orderFrontStandardAboutPanel:',
63-
},
64-
{ type: 'separator' },
65-
{ label: 'Services', submenu: [] },
66-
{ type: 'separator' },
67-
{
68-
label: 'Hide ElectronReact',
69-
accelerator: 'Command+H',
70-
selector: 'hide:',
71-
},
72-
{
73-
label: 'Hide Others',
74-
accelerator: 'Command+Shift+H',
75-
selector: 'hideOtherApplications:',
76-
},
77-
{ label: 'Show All', selector: 'unhideAllApplications:' },
61+
{ role: 'about' },
62+
...(isDev ? [{ type: 'separator' }, { role: 'services' }] : none),
7863
{ type: 'separator' },
79-
{
80-
label: 'Quit',
81-
accelerator: 'Command+Q',
82-
click: () => {
83-
app.quit();
84-
},
85-
},
86-
],
87-
};
88-
const subMenuEdit: DarwinMenuItemConstructorOptions = {
89-
label: 'Edit',
90-
submenu: [
91-
{ label: 'Undo', accelerator: 'Command+Z', selector: 'undo:' },
92-
{ label: 'Redo', accelerator: 'Shift+Command+Z', selector: 'redo:' },
64+
{ role: 'hide' },
65+
{ role: 'hideOthers' },
66+
{ role: 'unhide' },
9367
{ type: 'separator' },
94-
{ label: 'Cut', accelerator: 'Command+X', selector: 'cut:' },
95-
{ label: 'Copy', accelerator: 'Command+C', selector: 'copy:' },
96-
{ label: 'Paste', accelerator: 'Command+V', selector: 'paste:' },
97-
{
98-
label: 'Select All',
99-
accelerator: 'Command+A',
100-
selector: 'selectAll:',
101-
},
102-
],
103-
};
104-
const subMenuViewDev: MenuItemConstructorOptions = {
105-
label: 'View',
106-
submenu: [
107-
{
108-
label: 'Reload',
109-
accelerator: 'Command+R',
110-
click: () => {
111-
this.mainWindow.webContents.reload();
112-
},
113-
},
114-
{
115-
label: 'Toggle Full Screen',
116-
accelerator: 'Ctrl+Command+F',
117-
click: () => {
118-
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen());
119-
},
120-
},
121-
{
122-
label: 'Toggle Developer Tools',
123-
accelerator: 'Alt+Command+I',
124-
click: () => {
125-
this.mainWindow.webContents.toggleDevTools();
126-
},
127-
},
68+
{ role: 'quit' },
12869
],
12970
};
130-
const subMenuViewProd: MenuItemConstructorOptions = {
71+
const subMenuView: DarwinMenuItemConstructorOptions = {
13172
label: 'View',
13273
submenu: [
133-
{
134-
label: 'Toggle Full Screen',
135-
accelerator: 'Ctrl+Command+F',
136-
click: () => {
137-
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen());
138-
},
139-
},
140-
],
141-
};
142-
const subMenuWindow: DarwinMenuItemConstructorOptions = {
143-
label: 'Window',
144-
submenu: [
145-
{
146-
label: 'Minimize',
147-
accelerator: 'Command+M',
148-
selector: 'performMiniaturize:',
149-
},
150-
{ label: 'Close', accelerator: 'Command+W', selector: 'performClose:' },
74+
...(isDev
75+
? [
76+
{ role: 'reload' },
77+
{ role: 'forceReload' },
78+
{ role: 'toggleDevTools' },
79+
{ type: 'separator' },
80+
]
81+
: none),
82+
{ role: 'resetZoom' },
83+
{ role: 'zoomIn' },
84+
{ role: 'zoomOut' },
15185
{ type: 'separator' },
152-
{ label: 'Bring All to Front', selector: 'arrangeInFront:' },
153-
],
154-
};
155-
const subMenuHelp: MenuItemConstructorOptions = {
156-
label: 'Help',
157-
submenu: [
158-
{
159-
label: 'Learn More',
160-
click() {
161-
shell.openExternal('https://electronjs.org');
162-
},
163-
},
164-
{
165-
label: 'Documentation',
166-
click() {
167-
shell.openExternal(
168-
'https://github.com/electron/electron/tree/master/docs#readme'
169-
);
170-
},
171-
},
172-
{
173-
label: 'Community Discussions',
174-
click() {
175-
shell.openExternal('https://www.electronjs.org/community');
176-
},
177-
},
178-
{
179-
label: 'Search Issues',
180-
click() {
181-
shell.openExternal('https://github.com/electron/electron/issues');
182-
},
183-
},
86+
{ role: 'togglefullscreen' },
18487
],
18588
};
18689

187-
const subMenuView =
188-
process.env.NODE_ENV === 'development' ||
189-
process.env.DEBUG_PROD === 'true'
190-
? subMenuViewDev
191-
: subMenuViewProd;
192-
193-
return [subMenuAbout, subMenuEdit, subMenuView, subMenuWindow, subMenuHelp];
90+
return [
91+
subMenuApp,
92+
{ role: 'editMenu' },
93+
subMenuView,
94+
{ role: 'windowMenu' },
95+
];
19496
}
19597

19698
buildDefaultTemplate() {

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "time-tracker",
33
"productName": "TimeTracker",
4-
"version": "1.0.9",
4+
"version": "1.0.10",
55
"description": "Start and stop time, jump between tasks, and add details on how time was spent.",
66
"main": "./main.prod.js",
77
"author": {

src/services/gaService/GaService.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1-
import ua from 'universal-analytics';
1+
import ua, { Visitor } from 'universal-analytics';
2+
import { v4 as uuid } from 'uuid';
23

3-
const isProd = process.env.NODE_ENV === 'production';
4+
const isEnabled =
5+
process.env.NODE_ENV === 'production' ||
6+
process.env.FORCE_ENABLE_ANALYTICS === 'true';
47

58
const gaCode = process.env.GA_UACODE;
6-
let analytics: any | null = null;
79

8-
if (isProd && gaCode) {
9-
analytics = ua(gaCode);
10+
let analytics: Visitor | null = null;
11+
12+
if (isEnabled && gaCode) {
13+
let uid = window.localStorage.getItem('uid');
14+
15+
if (!uid) {
16+
uid = uuid();
17+
window.localStorage.setItem('uid', uid);
18+
}
19+
20+
analytics = ua(gaCode, uid);
1021
}
1122

1223
const executeOnCondition = (fn: () => void) => {
13-
if (isProd && analytics) {
24+
if (isEnabled && analytics) {
1425
fn();
1526
}
1627
};

src/shared/initSentry.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import log from 'electron-log';
2+
23
Object.assign(console, log.functions);
34

45
const Sentry =
@@ -7,7 +8,11 @@ const Sentry =
78
: require('@sentry/electron/dist/renderer');
89

910
export function initSentry() {
10-
if (process.env.NODE_ENV === 'production' && process.env.SENTRY_DSN) {
11+
if (
12+
(process.env.NODE_ENV === 'production' ||
13+
process.env.FORCE_ENABLE_SENTRY === 'true') &&
14+
process.env.SENTRY_DSN
15+
) {
1116
Sentry.init({
1217
dsn: process.env.SENTRY_DSN,
1318
});

src/types/Types.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
declare module 'universal-analytics' {
2-
const ua: (code: string) => any;
3-
4-
export default ua;
5-
}
6-
71
declare module 'react-hook-media-query' {
82
const useMediaQuery: (query: string) => boolean;
93

0 commit comments

Comments
 (0)