don't compress theme cache as it takes ~1secon on mobile

This commit is contained in:
Henry Jameson 2025-02-05 08:07:24 +02:00
parent f659c9c123
commit 9187c1d31c

View file

@ -93,18 +93,9 @@ export const generateTheme = (inputRuleset, callbacks, debug) => {
export const tryLoadCache = async () => {
console.info('Trying to load compiled theme data from cache')
const data = await localforage.getItem('pleromafe-theme-cache')
if (!data) return null
let cache
const cache = await localforage.getItem('pleromafe-theme-cache')
if (!cache) return null
try {
const inflated = pako.inflate(data)
const decoded = new TextDecoder().decode(inflated)
cache = JSON.parse(decoded)
console.info(`Loaded theme from cache, compressed=${Math.ceil(data.length / 1024)}kiB size=${Math.ceil(inflated.length / 1024)}kiB`)
} catch (e) {
console.error('Failed to decode theme cache:', e)
return false
}
if (cache.engineChecksum === getEngineChecksum()) {
const eagerStyles = createStyleSheet(EAGER_STYLE_ID)
const lazyStyles = createStyleSheet(LAZY_STYLE_ID)
@ -114,11 +105,16 @@ export const tryLoadCache = async () => {
adoptStyleSheets([eagerStyles, lazyStyles])
console.info(`Loaded theme from cache`)
return true
} else {
console.warn('Engine checksum doesn\'t match, cache not usable, clearing')
localStorage.removeItem('pleroma-fe-theme-cache')
}
} catch (e) {
console.error('Failed to load theme cache:', e)
return false
}
}
export const applyTheme = (