File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed
Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,6 @@ import { initializeSentry } from "./sentry"
1919import { router } from "./tipc"
2020import { createMainWindow , getMainWindow } from "./window"
2121
22- const appFolder = {
23- prod : "Follow" ,
24- dev : "Follow (dev)" ,
25- }
2622if ( process . argv . length === 3 && process . argv [ 2 ] . startsWith ( "follow-dev:" ) ) {
2723 process . env . NODE_ENV = "development"
2824}
@@ -32,7 +28,8 @@ const isDev = process.env.NODE_ENV === "development"
3228 * Mandatory and fast initializers for the app
3329 */
3430export function initializeAppStage0 ( ) {
35- app . setPath ( "appData" , path . join ( app . getPath ( "appData" ) , isDev ? appFolder . dev : appFolder . prod ) )
31+ if ( isDev ) app . setPath ( "appData" , path . join ( app . getPath ( "appData" ) , "Follow (dev)" ) )
32+ initializeSentry ( )
3633}
3734export const initializeAppStage1 = ( ) => {
3835 if ( process . defaultApp ) {
@@ -45,8 +42,6 @@ export const initializeAppStage1 = () => {
4542 app . setAsDefaultProtocolClient ( APP_PROTOCOL )
4643 }
4744
48- initializeSentry ( )
49-
5045 registerIpcMain ( router )
5146
5247 if ( app . dock ) {
Original file line number Diff line number Diff line change @@ -3,15 +3,26 @@ import { resolve } from "node:path"
33import { app } from "electron"
44import { JSONFileSyncPreset } from "lowdb/node"
55
6- const db = JSONFileSyncPreset ( resolve ( app . getPath ( "userData" ) , "db.json" ) , { } ) as {
6+ let db : {
77 data : Record < string , unknown >
88 write : ( ) => void
99 read : ( ) => void
1010}
1111
12+ const createOrGetDb = ( ) => {
13+ if ( ! db ) {
14+ db = JSONFileSyncPreset ( resolve ( app . getPath ( "userData" ) , "db.json" ) , { } ) as typeof db
15+ }
16+ return db
17+ }
1218export const store = {
13- get : ( key : string ) => db . data [ key ] as any ,
19+ get : ( key : string ) => {
20+ const db = createOrGetDb ( )
21+
22+ return db . data [ key ] as any
23+ } ,
1424 set : ( key : string , value : any ) => {
25+ const db = createOrGetDb ( )
1526 db . data [ key ] = value
1627 db . write ( )
1728 } ,
You can’t perform that action at this time.
0 commit comments