-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app APIConfig BackendList Config Logs Root AppConfigSideEffect ThemeS…
…witcher storage
- Loading branch information
Showing
10 changed files
with
73 additions
and
35 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
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,66 @@ | ||
import { useAtom } from 'jotai'; | ||
import { useEffect } from 'react'; | ||
|
||
import { saveState } from '$src/misc/storage'; | ||
import { debounce } from '$src/misc/utils'; | ||
import { | ||
autoCloseOldConnsAtom, | ||
clashAPIConfigsAtom, | ||
collapsibleIsOpenAtom, | ||
hideUnavailableProxiesAtom, | ||
latencyTestUrlAtom, | ||
logStreamingPausedAtom, | ||
proxySortByAtom, | ||
selectedChartStyleIndexAtom, | ||
selectedClashAPIConfigIndexAtom, | ||
themeAtom, | ||
} from '$src/store/app'; | ||
import { StateApp } from '$src/store/types'; | ||
|
||
let stateRef: StateApp; | ||
|
||
function save0() { | ||
if (stateRef) saveState(stateRef); | ||
} | ||
|
||
const save = debounce(save0, 500); | ||
|
||
export function AppConfigSideEffect() { | ||
const [selectedClashAPIConfigIndex] = useAtom(selectedClashAPIConfigIndexAtom); | ||
const [clashAPIConfigs] = useAtom(clashAPIConfigsAtom); | ||
const [latencyTestUrl] = useAtom(latencyTestUrlAtom); | ||
const [selectedChartStyleIndex] = useAtom(selectedChartStyleIndexAtom); | ||
const [theme] = useAtom(themeAtom); | ||
const [collapsibleIsOpen] = useAtom(collapsibleIsOpenAtom); | ||
const [proxySortBy] = useAtom(proxySortByAtom); | ||
const [hideUnavailableProxies] = useAtom(hideUnavailableProxiesAtom); | ||
const [autoCloseOldConns] = useAtom(autoCloseOldConnsAtom); | ||
const [logStreamingPaused] = useAtom(logStreamingPausedAtom); | ||
useEffect(() => { | ||
stateRef = { | ||
autoCloseOldConns, | ||
clashAPIConfigs, | ||
collapsibleIsOpen, | ||
hideUnavailableProxies, | ||
latencyTestUrl, | ||
logStreamingPaused, | ||
proxySortBy, | ||
selectedChartStyleIndex, | ||
selectedClashAPIConfigIndex, | ||
theme, | ||
} | ||
save(); | ||
}, [ | ||
autoCloseOldConns, | ||
clashAPIConfigs, | ||
collapsibleIsOpen, | ||
hideUnavailableProxies, | ||
latencyTestUrl, | ||
logStreamingPaused, | ||
proxySortBy, | ||
selectedChartStyleIndex, | ||
selectedClashAPIConfigIndex, | ||
theme, | ||
]); | ||
return null; | ||
} |
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