File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 790790 ChannelsEnum . RESPONSE_TOKEN_REFRESHING_FAILED ,
791791 ) ;
792792 } ) ;
793+ syncService . initialize ( {
794+ onSyncStatusChange : ( isSyncing ) => {
795+ mainWindow ?. webContents . send (
796+ ChannelsEnum . RESPONSE_SYNC_STATUS_CHANGE ,
797+ isSyncing ,
798+ ) ;
799+ } ,
800+ } ) ;
801+
793802 createWindow ( ) ;
794803 app . on ( 'activate' , ( ) => {
795804 log . info ( 'app activated' ) ;
Original file line number Diff line number Diff line change @@ -284,6 +284,8 @@ export class RepetitiveTaskTemplateService {
284284
285285 const isPremium = ! ! userId ;
286286
287+ let writeOperationOccurred = false ;
288+
287289 const processingPromises = dueTemplates . map ( ( template ) =>
288290 prisma . $transaction ( async ( tx ) => {
289291 const todayStart = dayjs ( ) . startOf ( 'day' ) ;
@@ -341,6 +343,7 @@ export class RepetitiveTaskTemplateService {
341343 ) ;
342344
343345 latestDueDateForTemplate = targetDueDate . toDate ( ) ;
346+ writeOperationOccurred = true ;
344347 }
345348 }
346349
@@ -369,7 +372,7 @@ export class RepetitiveTaskTemplateService {
369372 }
370373 } ) ;
371374
372- if ( isPremium ) {
375+ if ( isPremium && writeOperationOccurred ) {
373376 syncService . runSync ( ) ;
374377 }
375378 } ;
Original file line number Diff line number Diff line change @@ -143,26 +143,26 @@ const AppContextFn = (initialUser: User | null) => {
143143 if ( isSyncingRef . current ) return ;
144144
145145 isSyncingRef . current = true ;
146- setIsSyncing ( true ) ;
147146 try {
148147 await window . electron . ipcRenderer . invoke ( ChannelsEnum . REQUEST_SYNC_START ) ;
149148 } catch ( err : any ) {
150149 setNotifier ( err . message || 'Sync failed' , 'error' ) ;
151150 } finally {
152151 isSyncingRef . current = false ;
153- setIsSyncing ( false ) ;
154152 }
155153 } , [ setNotifier ] ) ;
156154
157155 const wasSyncing = useRef ( ! isSyncing ) ;
158156 useEffect ( ( ) => {
159- window . electron . ipcRenderer . on (
157+ // sourcery skip: inline-immediately-returned-variable
158+ const unsubscribe = window . electron . ipcRenderer . on (
160159 ChannelsEnum . RESPONSE_SYNC_STATUS_CHANGE ,
161160 ( _isSyncing : unknown ) => {
162161 setIsSyncing ( _isSyncing as boolean ) ;
163162 } ,
164163 ) ;
165- } ) ;
164+ return unsubscribe ;
165+ } , [ ] ) ;
166166
167167 useEffect ( ( ) => {
168168 if ( user && ! isSyncing && wasSyncing . current ) {
You can’t perform that action at this time.
0 commit comments