@@ -61,6 +61,9 @@ import { networkDataActions } from '../../state/ducks/networkData';
61
61
import { searchActions } from '../../state/ducks/search' ;
62
62
import { LUCIDE_ICONS_UNICODE } from '../icon/lucide' ;
63
63
import { AvatarMigrate } from '../../session/utils/job_runners/jobs/AvatarMigrateJob' ;
64
+ import { NetworkTime } from '../../util/NetworkTime' ;
65
+ import { Storage } from '../../util/storage' ;
66
+ import { getFileInfoFromFileServer } from '../../session/apis/file_server_api/FileServerApi' ;
64
67
65
68
const StyledContainerAvatar = styled . div `
66
69
padding: var(--margins-lg);
@@ -200,10 +203,10 @@ const triggerSyncIfNeeded = async () => {
200
203
} ;
201
204
202
205
const triggerAvatarReUploadIfNeeded = async ( ) => {
203
- const lastTimeStampAvatarUpload =
204
- ( await Data . getItemById ( SettingsKey . lastAvatarUploadTimestamp ) ) ?. value || 0 ;
206
+ const lastAvatarUploadExpiryMs =
207
+ ( await Data . getItemById ( SettingsKey . ntsAvatarExpiryMs ) ) ?. value || 0 ;
205
208
206
- if ( Date . now ( ) - lastTimeStampAvatarUpload > DURATION . DAYS * 14 ) {
209
+ if ( NetworkTime . now ( ) > lastAvatarUploadExpiryMs ) {
207
210
window . log . info ( 'Reuploading avatar...' ) ;
208
211
// reupload the avatar
209
212
await reuploadCurrentAvatarUs ( ) ;
@@ -243,10 +246,22 @@ const doAppStartUp = async () => {
243
246
void MessageQueue . use ( ) . processAllPending ( ) ;
244
247
} , 3000 ) ;
245
248
246
- global . setTimeout ( ( ) => {
249
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
250
+ global . setTimeout ( async ( ) => {
247
251
// Schedule a confSyncJob in some time to let anything incoming from the network be applied and see if there is a push needed
248
252
// Note: this also starts periodic jobs, so we don't need to keep doing it
249
- void UserSync . queueNewJobIfNeeded ( ) ;
253
+ await UserSync . queueNewJobIfNeeded ( ) ;
254
+
255
+ // on app startup, check that the avatar expiry on the file server
256
+ const avatarPointer = ConvoHub . use ( )
257
+ . get ( UserUtils . getOurPubKeyStrFromCache ( ) )
258
+ . getAvatarPointer ( ) ;
259
+ if ( avatarPointer ) {
260
+ const details = await getFileInfoFromFileServer ( avatarPointer ) ;
261
+ if ( details ?. expiryMs ) {
262
+ await Storage . put ( SettingsKey . ntsAvatarExpiryMs , details . expiryMs ) ;
263
+ }
264
+ }
250
265
} , 20000 ) ;
251
266
252
267
global . setTimeout ( ( ) => {
@@ -328,13 +343,16 @@ export const ActionsPanel = () => {
328
343
void SnodePool . forceRefreshRandomSnodePool ( ) ;
329
344
} , DURATION . MINUTES * 5 ) ;
330
345
331
- useInterval ( ( ) => {
332
- if ( ! ourPrimaryConversation ) {
333
- return ;
334
- }
335
- // this won't be run every days, but if the app stays open for more than 10 days
336
- void triggerAvatarReUploadIfNeeded ( ) ;
337
- } , DURATION . DAYS * 1 ) ;
346
+ useInterval (
347
+ ( ) => {
348
+ if ( ! ourPrimaryConversation ) {
349
+ return ;
350
+ }
351
+ // this won't be run every days, but if the app stays open for more than 10 days
352
+ void triggerAvatarReUploadIfNeeded ( ) ;
353
+ } ,
354
+ window . sessionFeatureFlags . fsTTL30s ? DURATION . SECONDS * 1 : DURATION . DAYS * 1
355
+ ) ;
338
356
339
357
useCheckReleasedFeatures ( ) ;
340
358
0 commit comments