fix and update
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { apiFetch, ensureApiGatewayReady, isApiGatewayReady, subscribeApiReady } from '@/lib/api';
|
||||
import { apiFetch } from '@/lib/api';
|
||||
|
||||
interface PublicSettingsContextValue {
|
||||
projectName: string;
|
||||
@@ -27,7 +27,6 @@ export function PublicSettingsProvider({ children }: { children: React.ReactNode
|
||||
|
||||
const refreshPublicSettings = useCallback(async () => {
|
||||
try {
|
||||
await ensureApiGatewayReady();
|
||||
const response = await apiFetch<{ settings: Array<{ key: string; value: string }> }>('/settings/public');
|
||||
const map = Object.fromEntries((response.settings ?? []).map((item) => [item.key, item.value]));
|
||||
setSettings(map);
|
||||
@@ -39,13 +38,7 @@ export function PublicSettingsProvider({ children }: { children: React.ReactNode
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (isApiGatewayReady()) {
|
||||
void refreshPublicSettings();
|
||||
return;
|
||||
}
|
||||
return subscribeApiReady(() => {
|
||||
void refreshPublicSettings();
|
||||
});
|
||||
void refreshPublicSettings();
|
||||
}, [refreshPublicSettings]);
|
||||
|
||||
const value = useMemo(
|
||||
|
||||
Reference in New Issue
Block a user