@@ -22,7 +22,6 @@ import { DecryptedAttachmentsManager } from '../../session/crypto/DecryptedAttac
2222
2323import { DURATION } from '../../session/constants' ;
2424
25- import { reuploadCurrentAvatarUs } from '../../interactions/avatar-interactions/nts-avatar-interactions' ;
2625import {
2726 onionPathModal ,
2827 updateDebugMenuModal ,
@@ -52,14 +51,13 @@ import { useDebugMode } from '../../state/selectors/debug';
5251import { networkDataActions } from '../../state/ducks/networkData' ;
5352import { LUCIDE_ICONS_UNICODE } from '../icon/lucide' ;
5453import { AvatarMigrate } from '../../session/utils/job_runners/jobs/AvatarMigrateJob' ;
55- import { NetworkTime } from '../../util/NetworkTime' ;
5654import { Storage } from '../../util/storage' ;
57- import { getFileInfoFromFileServer } from '../../session/apis/file_server_api/FileServerApi' ;
5855import { themesArray } from '../../themes/constants/colors' ;
5956import { isDebugMode , isDevProd } from '../../shared/env_vars' ;
6057import { GearAvatarButton } from '../buttons/avatar/GearAvatarButton' ;
6158import { useZoomShortcuts } from '../../hooks/useZoomingShortcut' ;
6259import { OnionStatusLight } from '../dialog/OnionStatusPathDialog' ;
60+ import { AvatarReupload } from '../../session/utils/job_runners/jobs/AvatarReuploadJob' ;
6361
6462const StyledContainerAvatar = styled . div `
6563 padding: var(--margins-lg);
@@ -98,17 +96,6 @@ const triggerSyncIfNeeded = async () => {
9896 }
9997} ;
10098
101- const triggerAvatarReUploadIfNeeded = async ( ) => {
102- const lastAvatarUploadExpiryMs =
103- ( await Data . getItemById ( SettingsKey . ntsAvatarExpiryMs ) ) ?. value || Number . MAX_SAFE_INTEGER ;
104-
105- if ( NetworkTime . now ( ) > lastAvatarUploadExpiryMs ) {
106- window . log . info ( 'Reuploading avatar...' ) ;
107- // reupload the avatar
108- await reuploadCurrentAvatarUs ( ) ;
109- }
110- } ;
111-
11299/**
113100 * This function is called only once: on app startup with a logged in user
114101 */
@@ -127,9 +114,8 @@ const doAppStartUp = async () => {
127114 } ) ; // refresh our swarm on start to speed up the first message fetching event
128115 void Data . cleanupOrphanedAttachments ( ) ;
129116
130- // TODOLATER make this a job of the JobRunner
131117 // Note: do not make this a debounce call (as for some reason it doesn't work with promises)
132- void triggerAvatarReUploadIfNeeded ( ) ;
118+ await AvatarReupload . addAvatarReuploadJob ( ) ;
133119
134120 /* Postpone a little bit of the polling of sogs messages to let the swarm messages come in first. */
135121 global . setTimeout ( ( ) => {
@@ -147,17 +133,6 @@ const doAppStartUp = async () => {
147133 // Schedule a confSyncJob in some time to let anything incoming from the network be applied and see if there is a push needed
148134 // Note: this also starts periodic jobs, so we don't need to keep doing it
149135 await UserSync . queueNewJobIfNeeded ( ) ;
150-
151- // on app startup, check that the avatar expiry on the file server
152- const avatarPointer = ConvoHub . use ( )
153- . get ( UserUtils . getOurPubKeyStrFromCache ( ) )
154- . getAvatarPointer ( ) ;
155- if ( avatarPointer ) {
156- const details = await getFileInfoFromFileServer ( avatarPointer ) ;
157- if ( details ?. expiryMs ) {
158- await Storage . put ( SettingsKey . ntsAvatarExpiryMs , details . expiryMs ) ;
159- }
160- }
161136 } , 20000 ) ;
162137
163138 global . setTimeout ( ( ) => {
@@ -283,8 +258,7 @@ export const ActionsPanel = () => {
283258 if ( ! ourPrimaryConversation ) {
284259 return ;
285260 }
286- // this won't be run every days, but if the app stays open for more than 10 days
287- void triggerAvatarReUploadIfNeeded ( ) ;
261+ void AvatarReupload . addAvatarReuploadJob ( ) ;
288262 } ,
289263 window . sessionFeatureFlags . fsTTL30s ? DURATION . SECONDS * 1 : DURATION . DAYS * 1
290264 ) ;
0 commit comments