Composer: Leverage serverTimeOffset for inline bot request caching

This commit is contained in:
Alexander Zinchuk 2021-08-16 20:45:26 +03:00
parent be4e05b8ca
commit 70b2404566

View File

@ -99,7 +99,7 @@ addReducer('loadTopInlineBots', (global) => {
const { serverTimeOffset } = global; const { serverTimeOffset } = global;
const { hash, lastRequestedAt } = global.topInlineBots; const { hash, lastRequestedAt } = global.topInlineBots;
if (lastRequestedAt && Date.now() + serverTimeOffset - lastRequestedAt < TOP_PEERS_REQUEST_COOLDOWN) { if (lastRequestedAt && Date.now() + serverTimeOffset * 1000 - lastRequestedAt < TOP_PEERS_REQUEST_COOLDOWN) {
return; return;
} }
@ -119,7 +119,7 @@ addReducer('loadTopInlineBots', (global) => {
...newGlobal.topInlineBots, ...newGlobal.topInlineBots,
hash: newHash, hash: newHash,
userIds: ids, userIds: ids,
lastRequestedAt: Date.now(), lastRequestedAt: Date.now() + serverTimeOffset * 1000,
}, },
}; };
setGlobal(newGlobal); setGlobal(newGlobal);