@ -44,6 +44,8 @@ const writeLastSyncTimestampToDb = async (timestamp: number) =>
* Conditionally Syncs user configuration with other devices linked .
* Conditionally Syncs user configuration with other devices linked .
* /
* /
export const syncConfigurationIfNeeded = async ( ) = > {
export const syncConfigurationIfNeeded = async ( ) = > {
await ConfigurationSync . queueNewJobIfNeeded ( ) ;
if ( ! window . sessionFeatureFlags . useSharedUtilForUserConfig ) {
if ( ! window . sessionFeatureFlags . useSharedUtilForUserConfig ) {
const lastSyncedTimestamp = ( await getLastSyncTimestampFromDb ( ) ) || 0 ;
const lastSyncedTimestamp = ( await getLastSyncTimestampFromDb ( ) ) || 0 ;
const now = Date . now ( ) ;
const now = Date . now ( ) ;
@ -70,8 +72,6 @@ export const syncConfigurationIfNeeded = async () => {
return ;
return ;
}
}
await writeLastSyncTimestampToDb ( now ) ;
await writeLastSyncTimestampToDb ( now ) ;
} else {
await ConfigurationSync . queueNewJobIfNeeded ( ) ;
}
}
} ;
} ;
@ -83,23 +83,24 @@ export const forceSyncConfigurationNowIfNeeded = async (waitForMessageSent = fal
resolve ( false ) ;
resolve ( false ) ;
} , 20000 ) ;
} , 20000 ) ;
if ( window . sessionFeatureFlags . useSharedUtilForUserConfig ) {
// the ConfigurationSync also handles dumping in to the DB if we do not need to push the data, but the dumping needs to be done even before the feature flag is true.
void ConfigurationSync . queueNewJobIfNeeded ( ) . catch ( e = > {
void ConfigurationSync . queueNewJobIfNeeded ( ) . catch ( e = > {
window . log . warn (
window . log . warn (
'forceSyncConfigurationNowIfNeeded scheduling of jobs failed with',
'forceSyncConfigurationNowIfNeeded scheduling of jobs ConfigurationSync.queueNewJobIfNeeded failed with: ',
e . message
e . message
) ;
) ;
} ) ;
} ) ;
if ( window . sessionFeatureFlags . useSharedUtilForUserConfig ) {
if ( waitForMessageSent ) {
if ( waitForMessageSent ) {
window . Whisper . events . once ( ConfigurationSyncJobDone , ( ) = > {
window . Whisper . events . once ( ConfigurationSyncJobDone , ( ) = > {
resolve ( true ) ;
resolve ( true ) ;
return ;
} ) ;
} ) ;
} else {
} else {
resolve ( true ) ;
resolve ( true ) ;
}
return ;
return ;
}
}
}
void getCurrentConfigurationMessage ( allConvos )
void getCurrentConfigurationMessage ( allConvos )
. then ( configMessage = > {
. then ( configMessage = > {