fix(frontend:api-keys): add flag to track successful API key fetch

this prevents the api from being spammed when the api keys have been successfully fetched but there are no keys
This commit is contained in:
2026-02-13 21:12:13 -05:00
parent ee45deb439
commit 78f4ae181e
@@ -57,6 +57,7 @@
let editDisplayNameValue = ''; let editDisplayNameValue = '';
let apiKeys: { uuid: string; name: string; createdAt: string; lastUsedAt: string | null }[] = []; let apiKeys: { uuid: string; name: string; createdAt: string; lastUsedAt: string | null }[] = [];
let successfullyFetchedApiKeys = false;
let newApiKeyName = ''; let newApiKeyName = '';
let newApiKeyValue = ''; let newApiKeyValue = '';
let isCreatingApiKey = false; let isCreatingApiKey = false;
@@ -269,6 +270,7 @@
const token = getToken(); const token = getToken();
if (!token) return; if (!token) return;
if (apiKeys.length > 0) return; if (apiKeys.length > 0) return;
if (successfullyFetchedApiKeys) return;
loading = true; loading = true;
try { try {
const res = await fetch('/api/auth/apikey/list', { const res = await fetch('/api/auth/apikey/list', {
@@ -277,6 +279,7 @@
if (res.ok) { if (res.ok) {
const json = await res.json(); const json = await res.json();
apiKeys = Array.isArray(json.apiKeys) ? json.apiKeys : []; apiKeys = Array.isArray(json.apiKeys) ? json.apiKeys : [];
successfullyFetchedApiKeys = json.successfullyFetchedApiKeys ?? true;
} }
} catch (e) { } catch (e) {
console.error('Failed to fetch API keys', e); console.error('Failed to fetch API keys', e);