Replaced server action with api route.
This commit is contained in:
@@ -1,12 +1,27 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useApp, setConfig } from '@/store/app';
|
||||
import { getConfig, Config } from '@/app/actions/getConfig';
|
||||
import { useApi } from '@/components/hooks/useApi';
|
||||
|
||||
export type Config = {
|
||||
cloudMode: boolean;
|
||||
cloudUrl?: string;
|
||||
faviconUrl?: string;
|
||||
linksUrl?: string;
|
||||
pixelsUrl?: string;
|
||||
privateMode: boolean;
|
||||
telemetryDisabled: boolean;
|
||||
trackerScriptName?: string;
|
||||
updatesDisabled: boolean;
|
||||
};
|
||||
|
||||
export function useConfig(): Config {
|
||||
const { config } = useApp();
|
||||
const { get } = useApi();
|
||||
|
||||
async function loadConfig() {
|
||||
setConfig(await getConfig());
|
||||
const { data } = await get(`/config`);
|
||||
|
||||
setConfig(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user