mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-13 18:32:20 +02:00
Squash Odysseus development history
This commit is contained in:
+9
-5
@@ -4,20 +4,21 @@
|
||||
* Search settings management — reads active provider from admin settings.
|
||||
*/
|
||||
|
||||
let API_BASE = '';
|
||||
import { getSettings, invalidateSettings } from './appConfig.js';
|
||||
|
||||
let _provider = 'searxng';
|
||||
let _loaded = false;
|
||||
|
||||
export function init(apiBase) {
|
||||
API_BASE = apiBase;
|
||||
// No API base parameter any more: the settings request lives in appConfig.js and
|
||||
// resolves against the document origin, which is exactly what API_BASE held.
|
||||
export function init() {
|
||||
// Fetch provider on init so it's ready when chat needs it
|
||||
_fetchProvider();
|
||||
}
|
||||
|
||||
async function _fetchProvider() {
|
||||
try {
|
||||
const res = await fetch((API_BASE || '') + '/api/auth/settings', { credentials: 'same-origin' });
|
||||
const s = await res.json();
|
||||
const s = await getSettings();
|
||||
_provider = s.search_provider || 'searxng';
|
||||
_loaded = true;
|
||||
} catch (e) { /* keep default */ }
|
||||
@@ -39,6 +40,9 @@ export function getProviderLabel() {
|
||||
|
||||
/** Re-fetch after admin saves new settings */
|
||||
export function refresh() {
|
||||
// Drop the shared snapshot first: the point of this call is to observe the
|
||||
// settings that were just written, so it must not be served from cache.
|
||||
invalidateSettings();
|
||||
_fetchProvider();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user