MCPcopy Create free account
hub / github.com/anomalyco/opencode / onStorage

Function onStorage

packages/ui/src/theme/context.tsx:231–250  ·  view source on GitHub ↗
(e: StorageEvent)

Source from the content-addressed store, hash-verified

229 const loadThemes = () => Promise.all(themeIDs().map(load)).then(() => store.themes)
230
231 const onStorage = (e: StorageEvent) => {
232 if (e.key === STORAGE_KEYS.THEME_ID && e.newValue) {
233 const next = normalize(e.newValue)
234 if (!next) return
235 if (next !== "oc-2" && !knownThemes().has(next) && !store.themes[next]) return
236 setStore("themeId", next)
237 if (next === "oc-2") {
238 clear()
239 return
240 }
241 void load(next).then((theme) => {
242 if (!theme || store.themeId !== next) return
243 cacheThemeVariants(theme, next)
244 })
245 }
246 if (e.key === STORAGE_KEYS.COLOR_SCHEME && e.newValue) {
247 setStore("colorScheme", e.newValue as ColorScheme)
248 setStore("mode", e.newValue === "system" ? getSystemMode() : (e.newValue as "light" | "dark"))
249 }
250 }
251
252 onMount(() => {
253 makeEventListener(window, "storage", onStorage)

Callers

nothing calls this directly

Calls 7

knownThemesFunction · 0.85
setStoreFunction · 0.85
cacheThemeVariantsFunction · 0.85
getSystemModeFunction · 0.85
normalizeFunction · 0.70
clearFunction · 0.70
loadFunction · 0.70

Tested by

no test coverage detected