()
| 29 | }) |
| 30 | |
| 31 | export const App = () => { |
| 32 | const [showSettingPanel, setShowSettingPanel] = useState(false) |
| 33 | const [state, actualDispatch] = useReducer(globalReducer, getDefaultGlobalState()) |
| 34 | |
| 35 | const dispatch: IGlobalDispatch = (info) => { |
| 36 | actualDispatch([info]) |
| 37 | } |
| 38 | |
| 39 | const toggleSettingPanel = () => { |
| 40 | setShowSettingPanel(!showSettingPanel) |
| 41 | } |
| 42 | |
| 43 | useEffectOnce(() => { |
| 44 | const cacheUserConfigStr = window.localStorage.getItem(CONSTS.USER_INFO_LOCAL_STORAGE) |
| 45 | |
| 46 | if (cacheUserConfigStr) { |
| 47 | const cacheUserConfig = JSON.parse(cacheUserConfigStr) as UserConfig |
| 48 | dispatch({ |
| 49 | type: 'userConfig', |
| 50 | value: cacheUserConfig, |
| 51 | }) |
| 52 | } |
| 53 | }) |
| 54 | |
| 55 | return ( |
| 56 | // eslint-disable-next-line |
| 57 | <GlobalContext.Provider value={{ state, dispatch, batchDispatch: actualDispatch }}> |
| 58 | <ThemeProvider theme={theme}> |
| 59 | <Box sx={{ flexGrow: 1 }}> |
| 60 | <AppBar position="relative"> |
| 61 | <Toolbar sx={{ minHeight: 46 }}> |
| 62 | <Typography variant="h6" component="div" sx={{ flexGrow: 1 }}> |
| 63 | Sync To Github |
| 64 | </Typography> |
| 65 | <IconButton |
| 66 | color="inherit" |
| 67 | aria-label="add an alarm" |
| 68 | sx={ |
| 69 | showSettingPanel |
| 70 | ? { |
| 71 | backgroundColor: 'rgba(0, 0, 0, 0.3)', |
| 72 | } |
| 73 | : {} |
| 74 | } |
| 75 | onClick={toggleSettingPanel} |
| 76 | > |
| 77 | <SettingsIcon /> |
| 78 | </IconButton> |
| 79 | </Toolbar> |
| 80 | </AppBar> |
| 81 | {!showSettingPanel && <SyncPanel />} |
| 82 | {showSettingPanel && <SettingPanel />} |
| 83 | </Box> |
| 84 | </ThemeProvider> |
| 85 | </GlobalContext.Provider> |
| 86 | ) |
| 87 | } |
nothing calls this directly
no test coverage detected