Skip to content

Commit

Permalink
fix: fixed store creation on initial install
Browse files Browse the repository at this point in the history
  • Loading branch information
Enubia committed Jun 24, 2023
1 parent a8f2dbf commit 6622683
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
- name: release artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm run release
run: pnpm run build-production
5 changes: 3 additions & 2 deletions electron/main/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ unhandled({
showDialog: true,
reportButton: async (error) => {
await fetch(
'https://discord.com/api/webhooks/1122136288783511612/IdvCR475_AuhXajrJ9DsOf805ypacPOUwt2bFp1fn9tpbjhEMcqVvPVtL6eMtG3nvDIM',
'https://discord.com/api/webhooks/1122184754465341570/9EjYJkd5zgwdAq_rQlNeX5PYZBHenE9ZCN-ZddlFbgOcIcKGJJrxlxGBiZeS3OzkjOOp',
{
method: 'POST',
headers: {
Expand All @@ -47,7 +47,8 @@ unhandled({
},
);

log.info('Crash report sent');
log.info('Crash report sent, exiting app');
process.exit(1);
},
});

Expand Down
12 changes: 10 additions & 2 deletions electron/main/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { unlinkSync } from 'node:fs';

import { app } from 'electron';
import ElectronStore from 'electron-store';

import { AppStore } from '../../shared/types';
Expand Down Expand Up @@ -47,11 +48,18 @@ export default function createStore() {
updater: {
channel: 'latest',
},

// Hack to make sure the store is always up to date at first init,
// default behavior of electron-store being to consider the store in version '0.0.0' by default
// @ts-ignore https://github.com/sindresorhus/electron-store/issues/256
__internal__: {
migrations: {
version: app.getVersion(),
},
},
},
// clears the config is a user edits it and causes a syntax error
clearInvalidConfig: true,
// used to reflect changes from main in renderer
watch: true,
migrations: {
'2.0.0': (store) => {
// delete store file initially
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"release": "vue-tsc --noEmit && vite build && electron-builder",
"build-production": "vue-tsc --noEmit && vite build && electron-builder",
"publish": "release-it",
"clean": "rimraf dist-electron dist release",
"lint:src": "eslint --cache --ext .ts --ignore-path .eslintignore src/",
Expand Down

0 comments on commit 6622683

Please sign in to comment.