-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
275a1c5
commit 47ea2fe
Showing
11 changed files
with
90 additions
and
119 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
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 |
---|---|---|
@@ -1,40 +1,21 @@ | ||
import { useCallback, useEffect, useState } from 'react'; | ||
import { settings } from '#preload'; | ||
import { DEPENDENCY_UPDATE_STRATEGY } from '/shared/types/settings'; | ||
import { useCallback } from 'react'; | ||
|
||
export const useSettings = () => { | ||
const [scenesPath, setScenesPath] = useState(''); | ||
const [updateDependenciesStrategy, setUpdateDependenciesStrategy] = | ||
useState<DEPENDENCY_UPDATE_STRATEGY>(DEPENDENCY_UPDATE_STRATEGY.NOTIFY); | ||
import { useDispatch, useSelector } from '#store'; | ||
|
||
const handleUpdateScenesPath = useCallback(async (path: string) => { | ||
await settings.setScenesPath(path); | ||
setScenesPath(path); | ||
}, []); | ||
import { type AppSettings } from '/shared/types/settings'; | ||
|
||
const handleUpdateDependenciesStrategy = useCallback( | ||
async (strategy: DEPENDENCY_UPDATE_STRATEGY) => { | ||
await settings.setUpdateDependenciesStrategy(strategy); | ||
setUpdateDependenciesStrategy(strategy); | ||
}, | ||
[], | ||
); | ||
import { actions as workspaceActions } from '/@/modules/store/workspace'; | ||
|
||
useEffect(() => { | ||
async function getAppSettings() { | ||
const path = await settings.getScenesPath(); | ||
const strategy = await settings.getUpdateDependenciesStrategy(); | ||
setScenesPath(path); | ||
setUpdateDependenciesStrategy(strategy); | ||
} | ||
export const useSettings = () => { | ||
const dispatch = useDispatch(); | ||
const { settings } = useSelector(state => state.workspace); | ||
|
||
getAppSettings(); | ||
const updateAppSettings = useCallback((settings: AppSettings) => { | ||
dispatch(workspaceActions.updateSettings(settings)); | ||
}, []); | ||
|
||
return { | ||
scenesPath, | ||
updateDependenciesStrategy, | ||
setScenesPath: handleUpdateScenesPath, | ||
setUpdateDependenciesStrategy: handleUpdateDependenciesStrategy, | ||
settings, | ||
updateAppSettings, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,13 +1,9 @@ | ||
import { type DEPENDENCY_UPDATE_STRATEGY } from './settings'; | ||
import { type AppSettings } from './settings'; | ||
|
||
export type Config = { | ||
version: number; | ||
workspace: { | ||
paths: string[]; | ||
}; | ||
} & AppSettings; | ||
|
||
export type AppSettings = { | ||
scenesPath?: string; | ||
updateDependenciesStrategy?: DEPENDENCY_UPDATE_STRATEGY; | ||
settings: AppSettings; | ||
}; |
Oops, something went wrong.