mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
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:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user