This commit is contained in:
yoan
2024-11-09 11:31:44 +08:00
parent 8809eef2ce
commit b06ffc0eef
9 changed files with 289 additions and 62 deletions

View File

@@ -8,6 +8,7 @@ export type NotifyContext = {
config: Setting<NotifyChannels>;
setChannel: (data: { channel: string; data: NotifyChannel }) => void;
setChannels: (data: Setting<NotifyChannels>) => void;
initChannels: () => void;
};
const Context = createContext({} as NotifyContext);
@@ -22,13 +23,18 @@ export const NotifyProvider = ({ children }: NotifyProviderProps) => {
const [notify, dispatchNotify] = useReducer(notifyReducer, {});
useEffect(() => {
const featchData = async () => {
const chanels = await getSetting<NotifyChannels>("notifyChannels");
dispatchNotify({
type: "SET_CHANNELS",
payload: chanels,
});
};
featchData();
}, []);
const featchData = async () => {
const chanels = await getSetting<NotifyChannels>("notifyChannels");
dispatchNotify({
type: "SET_CHANNELS",
payload: chanels,
});
};
const initChannels = useCallback(() => {
featchData();
}, []);
@@ -52,6 +58,7 @@ export const NotifyProvider = ({ children }: NotifyProviderProps) => {
config: notify,
setChannel,
setChannels,
initChannels,
}}
>
{children}