Successful remote config fetch should unexpire app

This commit is contained in:
Fedor Indutny 2024-02-06 11:25:58 -08:00 committed by GitHub
parent 533a1b32d4
commit fde9facad5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -76,6 +76,7 @@ export const refreshRemoteConfig = async (
): Promise<void> => {
const now = Date.now();
const { config: newConfig, serverEpochTime } = await server.getConfig();
const serverTimeSkew = serverEpochTime * SECOND - now;
if (Math.abs(serverTimeSkew) > HOUR) {
@ -127,6 +128,15 @@ export const refreshRemoteConfig = async (
};
}, {});
// If remote configuration fetch worked - we are not expired anymore.
if (
!getValue('desktop.clientExpiration') &&
window.storage.get('remoteBuildExpiration') != null
) {
log.warn('Remote Config: clearing remote expiration on successful fetch');
await window.storage.remove('remoteBuildExpiration');
}
await window.storage.put('remoteConfig', config);
await window.storage.put('serverTimeSkew', serverTimeSkew);
};