Cache
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect } from 'react'
|
||||
import { useLayoutEffect } from 'react'
|
||||
import { hexToOklch, calculateBrightness } from '@/lib/helpers/colorUtils'
|
||||
import { getCachedMenuColor, getRestaurantSlugFromPath, getThemeCache, applyCachedThemeToDom } from '@/lib/helpers/themeCache'
|
||||
|
||||
export function ThemeColorSetter() {
|
||||
useEffect(() => {
|
||||
useLayoutEffect(() => {
|
||||
try {
|
||||
const savedColor = localStorage.getItem('theme-primary-color')
|
||||
const slug = getRestaurantSlugFromPath()
|
||||
const cachedTheme = slug ? getThemeCache(slug) : null
|
||||
if (cachedTheme) {
|
||||
applyCachedThemeToDom(cachedTheme)
|
||||
return
|
||||
}
|
||||
|
||||
const savedColor = getCachedMenuColor(slug)
|
||||
if (savedColor) {
|
||||
const oklchColor = hexToOklch(savedColor)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user