feat: Align conditional fetching with conditional rendering for API Keys and Channels (#118) (#20043)
Fixes #19967 Co-authored-by: Tim Baek <tim@openwebui.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Tim Baek
Claude
parent
149bb9dae2
commit
3d5aaa9ead
@@ -109,10 +109,17 @@
|
|||||||
|
|
||||||
webhookUrl = $settings?.notifications?.webhook_url ?? '';
|
webhookUrl = $settings?.notifications?.webhook_url ?? '';
|
||||||
|
|
||||||
APIKey = await getAPIKey(localStorage.token).catch((error) => {
|
// Only fetch API key if the feature is enabled and user has permission
|
||||||
console.log(error);
|
if (
|
||||||
return '';
|
user &&
|
||||||
});
|
($config?.features?.enable_api_keys ?? true) &&
|
||||||
|
(user?.role === 'admin' || (user?.permissions?.features?.api_keys ?? false))
|
||||||
|
) {
|
||||||
|
APIKey = await getAPIKey(localStorage.token).catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -455,7 +455,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
await initChannels();
|
// Only fetch channels if the feature is enabled and user has permission
|
||||||
|
if (
|
||||||
|
$config?.features?.enable_channels &&
|
||||||
|
($user?.role === 'admin' || ($user?.permissions?.features?.channels ?? true))
|
||||||
|
) {
|
||||||
|
await initChannels();
|
||||||
|
}
|
||||||
await initChatList();
|
await initChatList();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user