-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ability to set developer mode in desktop client
- Loading branch information
Showing
7 changed files
with
107 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { createContext, useEffect, useState } from 'react' | ||
|
||
interface DevModeContextType { | ||
devMode: boolean | ||
checkDevMode: () => void | ||
setDevMode: (devMode: boolean) => void | ||
} | ||
|
||
const DevModeContext = createContext<DevModeContextType>({ | ||
devMode: false, | ||
checkDevMode: () => {}, | ||
setDevMode: () => {} | ||
}) | ||
|
||
interface DevModeContextProviderProps { | ||
children: React.ReactNode | ||
} | ||
|
||
const DevModeContextProvider = ({ | ||
children | ||
}: DevModeContextProviderProps) => { | ||
const [devMode, _setDevMode] = useState(false) | ||
|
||
async function checkDevMode() { | ||
const isDev = await window.api.isDevMode() | ||
_setDevMode(isDev) | ||
} | ||
|
||
async function setDevMode(dev: boolean) { | ||
await window.api.setStorageValue('devMode', dev) | ||
await checkDevMode() | ||
} | ||
|
||
useEffect(() => { | ||
checkDevMode() | ||
}, []) | ||
|
||
return ( | ||
<DevModeContext.Provider | ||
value={{ | ||
devMode, | ||
checkDevMode, | ||
setDevMode | ||
}} | ||
> | ||
{children} | ||
</DevModeContext.Provider> | ||
) | ||
} | ||
|
||
export { DevModeContext, DevModeContextProvider } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters