Display BanGUI version in dashboard and server config UI
This commit is contained in:
@@ -17,6 +17,8 @@ const POLL_INTERVAL_MS = 30_000;
|
||||
export interface UseServerStatusResult {
|
||||
/** The most recent server status snapshot, or `null` before the first fetch. */
|
||||
status: ServerStatus | null;
|
||||
/** BanGUI application version string. */
|
||||
banguiVersion: string | null;
|
||||
/** Whether a fetch is currently in flight. */
|
||||
loading: boolean;
|
||||
/** Error message string when the last fetch failed, otherwise `null`. */
|
||||
@@ -32,6 +34,7 @@ export interface UseServerStatusResult {
|
||||
*/
|
||||
export function useServerStatus(): UseServerStatusResult {
|
||||
const [status, setStatus] = useState<ServerStatus | null>(null);
|
||||
const [banguiVersion, setBanguiVersion] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
@@ -43,6 +46,7 @@ export function useServerStatus(): UseServerStatusResult {
|
||||
try {
|
||||
const data = await fetchServerStatus();
|
||||
setStatus(data.status);
|
||||
setBanguiVersion(data.bangui_version);
|
||||
setError(null);
|
||||
} catch (err: unknown) {
|
||||
setError(err instanceof Error ? err.message : "Failed to fetch server status");
|
||||
@@ -77,5 +81,5 @@ export function useServerStatus(): UseServerStatusResult {
|
||||
void doFetch().catch((): void => undefined);
|
||||
}, [doFetch]);
|
||||
|
||||
return { status, loading, error, refresh };
|
||||
return { status, banguiVersion, loading, error, refresh };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user