checksum -> engineChecksum for clarity
This commit is contained in:
parent
af236d71f0
commit
6ea69eb51a
|
@ -1,6 +1,6 @@
|
||||||
import { hex2rgb } from '../color_convert/color_convert.js'
|
import { hex2rgb } from '../color_convert/color_convert.js'
|
||||||
import { generatePreset } from '../theme_data/theme_data.service.js'
|
import { generatePreset } from '../theme_data/theme_data.service.js'
|
||||||
import { init, getChecksum } from '../theme_data/theme_data_3.service.js'
|
import { init, getEngineChecksum } from '../theme_data/theme_data_3.service.js'
|
||||||
import { convertTheme2To3 } from '../theme_data/theme2_to_theme3.js'
|
import { convertTheme2To3 } from '../theme_data/theme2_to_theme3.js'
|
||||||
import { getCssRules } from '../theme_data/css_utils.js'
|
import { getCssRules } from '../theme_data/css_utils.js'
|
||||||
import { defaultState } from '../../modules/config.js'
|
import { defaultState } from '../../modules/config.js'
|
||||||
|
@ -97,7 +97,7 @@ export const tryLoadCache = () => {
|
||||||
console.error('Failed to decode theme cache:', e)
|
console.error('Failed to decode theme cache:', e)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (cache.checksum === getChecksum()) {
|
if (cache.engineChecksum === getEngineChecksum()) {
|
||||||
const styleSheet = new CSSStyleSheet()
|
const styleSheet = new CSSStyleSheet()
|
||||||
const lazyStyleSheet = new CSSStyleSheet()
|
const lazyStyleSheet = new CSSStyleSheet()
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ export const tryLoadCache = () => {
|
||||||
|
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
console.warn('Checksum doesn\'t match, cache not usable, clearing')
|
console.warn('Engine checksum doesn\'t match, cache not usable, clearing')
|
||||||
localStorage.removeItem('pleroma-fe-theme-cache')
|
localStorage.removeItem('pleroma-fe-theme-cache')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ export const applyTheme = async (input, onFinish = (data) => {}) => {
|
||||||
},
|
},
|
||||||
onLazyFinished () {
|
onLazyFinished () {
|
||||||
document.adoptedStyleSheets = [styleSheet, lazyStyleSheet]
|
document.adoptedStyleSheets = [styleSheet, lazyStyleSheet]
|
||||||
const cache = { checksum: getChecksum(), data: [styleArray, lazyStyleArray] }
|
const cache = { engineChecksum: getEngineChecksum(), data: [styleArray, lazyStyleArray] }
|
||||||
onFinish(cache)
|
onFinish(cache)
|
||||||
localStorage.setItem('pleroma-fe-theme-cache', JSON.stringify(cache))
|
localStorage.setItem('pleroma-fe-theme-cache', JSON.stringify(cache))
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,11 +143,11 @@ componentsContext.keys().forEach(key => {
|
||||||
components[component.name] = component
|
components[component.name] = component
|
||||||
})
|
})
|
||||||
|
|
||||||
const checksum = sum(components)
|
const engineChecksum = sum(components)
|
||||||
|
|
||||||
const ruleToSelector = genericRuleToSelector(components)
|
const ruleToSelector = genericRuleToSelector(components)
|
||||||
|
|
||||||
export const getChecksum = () => checksum
|
export const getEngineChecksum = () => engineChecksum
|
||||||
|
|
||||||
export const init = (extraRuleset, ultimateBackgroundColor) => {
|
export const init = (extraRuleset, ultimateBackgroundColor) => {
|
||||||
const staticVars = {}
|
const staticVars = {}
|
||||||
|
@ -469,6 +469,6 @@ export const init = (extraRuleset, ultimateBackgroundColor) => {
|
||||||
lazy: result.filter(x => typeof x === 'function'),
|
lazy: result.filter(x => typeof x === 'function'),
|
||||||
eager: result.filter(x => typeof x !== 'function'),
|
eager: result.filter(x => typeof x !== 'function'),
|
||||||
staticVars,
|
staticVars,
|
||||||
checksum
|
engineChecksum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue