MCPcopy Create free account
hub / github.com/Moebytes/Frame-Player / LocalStorage

Function LocalStorage

LocalStorage.tsx:40–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38}
39
40const LocalStorage: React.FunctionComponent = () => {
41 const {theme, os, transparent, pinned} = useThemeSelector()
42 const {setTheme, setOS, setTransparent, setPinned} = useThemeActions()
43 const {videoDrag} = useActiveSelector()
44 const {setVideoDrag} = useActiveActions()
45
46 useEffect(() => {
47 if (typeof window === "undefined") return
48 const colorList = theme.includes("light") ? lightColorList : darkColorList
49
50 for (let i = 0; i < Object.keys(colorList).length; i++) {
51 const key = Object.keys(colorList)[i]
52 const color = Object.values(colorList)[i]
53 document.documentElement.style.setProperty(key, color)
54 }
55
56 if (transparent) {
57 document.documentElement.style.setProperty("--background", "transparent")
58 document.documentElement.style.setProperty("--navColor", "transparent")
59 }
60 }, [theme, transparent])
61
62 useEffect(() => {
63 const initTheme = async () => {
64 const savedTheme = await window.ipcRenderer.invoke("get-theme")
65 if (savedTheme) setTheme(savedTheme as Themes)
66 }
67 initTheme()
68 }, [])
69
70 useEffect(() => {
71 window.ipcRenderer.invoke("save-theme", theme)
72 }, [theme])
73
74 useEffect(() => {
75 const initOS = async () => {
76 const savedOS = await window.ipcRenderer.invoke("get-os")
77 if (savedOS) setOS(savedOS as OS)
78 }
79 initOS()
80 }, [])
81
82 useEffect(() => {
83 window.ipcRenderer.invoke("save-os", os)
84 }, [os])
85
86 useEffect(() => {
87 const initOS = async () => {
88 const savedTransparent = await window.ipcRenderer.invoke("get-transparent")
89 if (savedTransparent) setTransparent(savedTransparent)
90 }
91 initOS()
92 }, [])
93
94 useEffect(() => {
95 window.ipcRenderer.invoke("save-transparent", transparent)
96 }, [transparent])
97

Callers

nothing calls this directly

Calls 8

useThemeSelectorFunction · 0.85
useThemeActionsFunction · 0.85
useActiveSelectorFunction · 0.85
useActiveActionsFunction · 0.85
initThemeFunction · 0.85
initOSFunction · 0.85
initPinnedFunction · 0.85
initVideoDragFunction · 0.85

Tested by

no test coverage detected