Merge pull request #953 from ente-io/continuous-sync

Continuous sync
This commit is contained in:
Abhinav Kumar 2023-02-23 16:30:56 +05:30 committed by GitHub
commit afc357c385
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 0 deletions

View file

@ -11,3 +11,5 @@ export enum PLAN_PERIOD {
MONTH = 'month',
YEAR = 'year',
}
export const SYNC_INTERVAL_IN_MICROSECONDS = 1000 * 60 * 5; // 5 minutes

View file

@ -105,6 +105,8 @@ import { User } from 'types/user';
import { getData, LS_KEYS } from 'utils/storage/localStorage';
import { CenteredFlex } from 'components/Container';
import { checkConnectivity } from 'utils/error/ui';
import { SYNC_INTERVAL_IN_MICROSECONDS } from 'constants/gallery';
import ElectronService from 'services/electron/common';
import uploadManager from 'services/upload/uploadManager';
export const DeadCenter = styled('div')`
@ -262,6 +264,12 @@ export default function Gallery() {
setIsFirstLoad(false);
setJustSignedUp(false);
setIsFirstFetch(false);
setInterval(() => {
syncWithRemote(false, true);
}, SYNC_INTERVAL_IN_MICROSECONDS);
ElectronService.registerForegroundEventListener(() =>
syncWithRemote(false, true)
);
};
main();
}, []);

View file

@ -39,6 +39,11 @@ class ElectronService {
return this.electronAPIs.logRendererProcessMemoryUsage(message);
}
}
registerForegroundEventListener(onForeground: () => void) {
if (this.electronAPIs?.registerForegroundEventListener) {
this.electronAPIs.registerForegroundEventListener(onForeground);
}
}
}
export default new ElectronService();

View file

@ -93,4 +93,5 @@ export interface ElectronAPIs {
maxSize: number
) => Promise<Uint8Array>;
logRendererProcessMemoryUsage: (message: string) => Promise<void>;
registerForegroundEventListener: (onForeground: () => void) => void;
}