fix: correct broken throttle in checkAuth that never triggered

The throttle checked `lastUserInfoRefresh > now + 1 minute` which is
never true since lastUserInfoRefresh is set to the current time.
Changed to `now - 1 minute` so the check actually prevents redundant
API calls within a one-minute window.
This commit is contained in:
kolaente 2026-02-21 22:29:04 +01:00
parent 1dc625f9e8
commit a11cde1afc
1 changed files with 2 additions and 2 deletions

View File

@ -272,12 +272,12 @@ export const useAuthStore = defineStore('auth', () => {
*/
async function checkAuth() {
const now = new Date()
const inOneMinute = new Date(new Date().setMinutes(now.getMinutes() + 1))
const oneMinuteAgo = new Date(new Date().setMinutes(now.getMinutes() - 1))
// This function can be called from multiple places at the same time and shortly after one another.
// To prevent hitting the api too frequently or race conditions, we check at most once per minute.
if (
lastUserInfoRefresh.value !== null &&
lastUserInfoRefresh.value > inOneMinute
lastUserInfoRefresh.value > oneMinuteAgo
) {
return
}