Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #411 Javascript Error #414

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,24 @@

## [1.3.0](https://github.com/zidoro/pomatez/compare/v1.2.3...v1.3.0) (2023-09-26)


### Features ✨

* add support for open at login in the settings tab ([f57e133](https://github.com/zidoro/pomatez/commit/f57e1335d59938d95c6de4455b96aafcc8a878a2))
* increase maximum focus time to 2 hours ([#383](https://github.com/zidoro/pomatez/issues/383)) ([3fc1493](https://github.com/zidoro/pomatez/commit/3fc14937ee4b08e74390fbd36eb115278f55f179))

- add support for open at login in the settings tab ([f57e133](https://github.com/zidoro/pomatez/commit/f57e1335d59938d95c6de4455b96aafcc8a878a2))
- increase maximum focus time to 2 hours ([#383](https://github.com/zidoro/pomatez/issues/383)) ([3fc1493](https://github.com/zidoro/pomatez/commit/3fc14937ee4b08e74390fbd36eb115278f55f179))

### Bug Fixes 🐛

* compact mode layout broke with 120 minutes max timer config ([#393](https://github.com/zidoro/pomatez/issues/393)) ([c8c3c66](https://github.com/zidoro/pomatez/commit/c8c3c66460116aefe8a172b4237fa08b52583ffc))
* disable dragging for navigation links ([#387](https://github.com/zidoro/pomatez/issues/387)) ([a5b147f](https://github.com/zidoro/pomatez/commit/a5b147fbac812b2be6e92ce218841bfebe29d790))
* fix security issues ([bcbd65f](https://github.com/zidoro/pomatez/commit/bcbd65fa18d5f5531b20ab2ee0462b03ec766b5c)), closes [#407](https://github.com/zidoro/pomatez/issues/407)
* notification type selection issue in settings ([04ddca1](https://github.com/zidoro/pomatez/commit/04ddca16023bfea1b6496d41769ee7715700354d))
- compact mode layout broke with 120 minutes max timer config ([#393](https://github.com/zidoro/pomatez/issues/393)) ([c8c3c66](https://github.com/zidoro/pomatez/commit/c8c3c66460116aefe8a172b4237fa08b52583ffc))
- disable dragging for navigation links ([#387](https://github.com/zidoro/pomatez/issues/387)) ([a5b147f](https://github.com/zidoro/pomatez/commit/a5b147fbac812b2be6e92ce218841bfebe29d790))
- fix security issues ([bcbd65f](https://github.com/zidoro/pomatez/commit/bcbd65fa18d5f5531b20ab2ee0462b03ec766b5c)), closes [#407](https://github.com/zidoro/pomatez/issues/407)
- notification type selection issue in settings ([04ddca1](https://github.com/zidoro/pomatez/commit/04ddca16023bfea1b6496d41769ee7715700354d))

## [1.2.3](https://github.com/zidoro/pomatez/compare/v1.2.2...v1.2.3) (2023-05-03)


### Bug Fixes 🐛

* **app/renderer:** fix linter warnings that causes CI test build failing ([26edd59](https://github.com/zidoro/pomatez/commit/26edd59b26155954208fafc0dc3d933501c11bc9))
* Set Application Menu to Fix Mac Shortcuts ([0e6d47f](https://github.com/zidoro/pomatez/commit/0e6d47f0eb166256f914494518b4ea9e63160c06))
- **app/renderer:** fix linter warnings that causes CI test build failing ([26edd59](https://github.com/zidoro/pomatez/commit/26edd59b26155954208fafc0dc3d933501c11bc9))
- Set Application Menu to Fix Mac Shortcuts ([0e6d47f](https://github.com/zidoro/pomatez/commit/0e6d47f0eb166256f914494518b4ea9e63160c06))

## [1.2.2](https://github.com/zidoro/pomatez/compare/v1.2.1...v1.2.2) (2022-12-21)

Expand Down
2 changes: 1 addition & 1 deletion app/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"prepare": "yarn build",
"clean": "rimraf dist/ build/",
"predev:main": "wait-on http://localhost:3000",
"predev:main": "wait-on http://127.0.0.1:3000",
"dev:main": "nodemon --exec \"yarn build && electron .\"",
"start": "yarn dev:main",
"build": "tsc && copyfiles -u 2 \"src/assets/*\" build/assets",
Expand Down
4 changes: 2 additions & 2 deletions app/main/src/helpers/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { v4 as uuid } from "uuid";

import store from "../store";

const userId = store.get("userId") || uuid();
const userId = store.safeGet("userId") || uuid();

store.set("userId", userId);
store.safeSet("userId", userId);

function activateUser() {
const user = ua("UA-172128342-2", userId);
Expand Down
18 changes: 10 additions & 8 deletions app/main/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const getFrameHeight = () => {
if (isWindow()) {
return 502;
} else {
if (store.get("useNativeTitlebar")) {
if (store.safeGet("useNativeTitlebar")) {
return 488;
}
return 502;
Expand All @@ -91,9 +91,9 @@ function createMainWindow() {
resizable: true,
maximizable: false,
show: false,
frame: store.get("useNativeTitlebar"),
frame: store.safeGet("useNativeTitlebar"),
icon: getIcon(),
backgroundColor: store.get("isDarkMode") ? "#141e25" : "#fff",
backgroundColor: store.safeGet("isDarkMode") ? "#141e25" : "#fff",
webPreferences: {
contextIsolation: true,
backgroundThrottling: false,
Expand Down Expand Up @@ -314,7 +314,9 @@ if (!onlySingleInstance) {
},
(err, response) => {
if (!err) {
shell.openExternal(RELEASED_NOTES_LINK);
if (response === "view released notes") {
shell.openExternal(RELEASED_NOTES_LINK);
}
}
}
);
Expand Down Expand Up @@ -372,7 +374,7 @@ ipcMain.on(SET_COMPACT_MODE, (e, args) => {
});

ipcMain.on(SET_UI_THEME, (e, { isDarkMode }) => {
store.set("isDarkMode", isDarkMode);
store.safeSet("isDarkMode", isDarkMode);
});

ipcMain.on(SET_SHOW, () => {
Expand Down Expand Up @@ -406,8 +408,8 @@ ipcMain.on(SET_CLOSE, (e, { closeToTray }) => {
});

ipcMain.on(SET_NATIVE_TITLEBAR, (e, { useNativeTitlebar }) => {
if (store.get("useNativeTitlebar") !== useNativeTitlebar) {
store.set("useNativeTitlebar", useNativeTitlebar);
if (store.safeGet("useNativeTitlebar") !== useNativeTitlebar) {
store.safeSet("useNativeTitlebar", useNativeTitlebar);
setTimeout(() => {
app.relaunch();
app.exit();
Expand All @@ -421,7 +423,7 @@ ipcMain.on(TRAY_ICON_UPDATE, (e, dataUrl) => {
});

ipcMain.on(SET_OPEN_AT_LOGIN, (e, { openAtLogin }) => {
store.set("openAtLogin", openAtLogin);
store.safeSet("openAtLogin", openAtLogin);
app.setLoginItemSettings({
openAtLogin: openAtLogin,
openAsHidden: openAtLogin,
Expand Down
46 changes: 44 additions & 2 deletions app/main/src/store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Store from "electron-store";
import Store, { Options } from "electron-store";
import { nativeTheme } from "electron";
import { isWindow } from "./helpers";
import ElectronStore from "electron-store";

type StoreProps = {
userId?: string;
Expand All @@ -10,7 +11,48 @@ type StoreProps = {
openAtLogin?: boolean;
};

const store = new Store<StoreProps>({
/**
* Was going to make SafeStore extend Store but it didn't seem to work how it should. (Class constructor ElectronStore cannot be invoked without 'new')
*
* This also ensures that we can force calling the store safely. Though I have switched the names to safeGet and safeSet to make it more clear.
*/
class SafeStore<
T extends Record<string, any> = Record<string, unknown>,
> {
private store: ElectronStore<T>;
constructor(props: Options<T>) {
this.store = new Store<T>(props);
}

/**
* Safely set a value in the store and catch errors
* @param key
* @param value
*/
safeSet<Key extends keyof T>(key: Key, value?: T[Key]) {
try {
this.store.set(key, value);
} catch (error) {
console.error("[Store] Safe Set", error);
}
}

/**
* Safely get a value from the store and catch errors
* @param key
*/
safeGet<Key extends keyof T>(key: Key): T[Key] | undefined {
try {
return this.store.get(key);
} catch (error) {
console.error("[Store] Safe Get", error);
}
return undefined;
}
}

// Wrap the store due to a delete issue
const store = new SafeStore<StoreProps>({
defaults: {
isDarkMode: nativeTheme.shouldUseDarkColors,
useNativeTitlebar: !isWindow(),
Expand Down
4 changes: 3 additions & 1 deletion app/renderer/src/styles/routes/tasks/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export const StyledCard = styled.div<CardProps>`
border-bottom-color: var(--color-border-input-secondary);
background-color: var(--color-bg-task-card);

transition: box-shadow 320ms ease-out, background-color 320ms ease-out,
:w transition:
box-shadow 320ms ease-out,
background-color 320ms ease-out,
border-color 320ms ease-out;

${(p) =>
Expand Down