Skip to content

Commit 662f82d

Browse files
committed
Implemented the WelcomeDialog into the ConfigContext.jsx
1 parent d356cf7 commit 662f82d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

client/src/common/contexts/Config/ConfigContext.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import React, {createContext, useContext, useEffect, useState} from "react";
22
import {InputDialogContext} from "../InputDialog";
33
import {request} from "@/common/utils/RequestUtil";
44
import {apiErrorDialog, passwordRequiredDialog} from "@/common/contexts/Config/dialog";
5+
import WelcomeDialog from "@/common/components/WelcomeDialog";
56

67
export const ConfigContext = createContext({});
78

89
export const ConfigProvider = (props) => {
910
const [config, setConfig] = useState({});
1011
const [setDialog] = useContext(InputDialogContext);
12+
const [welcomeShown, setWelcomeShown] = useState(false);
13+
1114

1215
const reloadConfig = () => {
1316
request("/config").then(async res => {
@@ -33,8 +36,13 @@ export const ConfigProvider = (props) => {
3336

3437
useEffect(reloadConfig, []);
3538

39+
useEffect(() => {
40+
if (config.provider === "none") setWelcomeShown(true);
41+
}, [config]);
42+
3643
return (
3744
<ConfigContext.Provider value={[config, reloadConfig, checkConfig]}>
45+
{welcomeShown && <WelcomeDialog onClose={() => setWelcomeShown(false)}/>}
3846
{props.children}
3947
</ConfigContext.Provider>
4048
)

0 commit comments

Comments
 (0)