Merge remote-tracking branch 'origin/develop' into users-statuses-pinia
This commit is contained in:
commit
657f405ee0
27 changed files with 167 additions and 20 deletions
|
|
@ -92,6 +92,11 @@ export const adoptStyleSheets = throttle(() => {
|
|||
const EAGER_STYLE_ID = 'pleroma-eager-styles'
|
||||
const LAZY_STYLE_ID = 'pleroma-lazy-styles'
|
||||
|
||||
export const hasInvalidCachedThemeRules = (data) =>
|
||||
data
|
||||
.flat()
|
||||
.some((rule) => /--(?:mono)?font:\s*\[object Object\](?:;|$)/i.test(rule))
|
||||
|
||||
const generateTheme = (inputRuleset, callbacks, debug) => {
|
||||
const {
|
||||
onNewRule = () => {
|
||||
|
|
@ -151,7 +156,8 @@ export const tryLoadCache = async () => {
|
|||
if (
|
||||
cache.engineChecksum === getEngineChecksum() &&
|
||||
cache.checksum !== undefined &&
|
||||
cache.checksum === useMergedConfigStore().mergedConfig.themeChecksum
|
||||
cache.checksum === useMergedConfigStore().mergedConfig.themeChecksum &&
|
||||
!hasInvalidCachedThemeRules(cache.data)
|
||||
) {
|
||||
const eagerStyles = createStyleSheet(EAGER_STYLE_ID, 10)
|
||||
const lazyStyles = createStyleSheet(LAZY_STYLE_ID, 20)
|
||||
|
|
@ -307,7 +313,9 @@ export const applyStyleConfig = (input) => {
|
|||
adoptStyleSheets()
|
||||
}
|
||||
|
||||
export const getResourcesIndex = async (url, parser = (x) => x) => {
|
||||
const noop = (x) => x
|
||||
|
||||
export const getResourcesIndex = async (url, parser = noop) => {
|
||||
const cache = 'no-store'
|
||||
const customUrl = url.replace(/\.(\w+)$/, '.custom.$1')
|
||||
let builtin
|
||||
|
|
@ -324,6 +332,7 @@ export const getResourcesIndex = async (url, parser = (x) => x) => {
|
|||
promisedRequest({
|
||||
url: v,
|
||||
cache,
|
||||
forceContentType: parser === noop ? null : 'text/plain',
|
||||
})
|
||||
.then(({ data: text }) => parser(text))
|
||||
.catch((e) => {
|
||||
|
|
@ -339,7 +348,11 @@ export const getResourcesIndex = async (url, parser = (x) => x) => {
|
|||
}
|
||||
|
||||
try {
|
||||
const { data: builtinData } = await promisedRequest({ url, cache })
|
||||
const { data: builtinData } = await promisedRequest({
|
||||
url,
|
||||
cache,
|
||||
forceContentType: 'application/json',
|
||||
})
|
||||
builtin = resourceTransform(builtinData)
|
||||
} catch {
|
||||
builtin = []
|
||||
|
|
@ -350,6 +363,7 @@ export const getResourcesIndex = async (url, parser = (x) => x) => {
|
|||
const { data: customData } = await promisedRequest({
|
||||
url: customUrl,
|
||||
cache,
|
||||
forceContentType: 'application/json',
|
||||
})
|
||||
custom = resourceTransform(customData)
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ export const convertTheme2To3 = (data) => {
|
|||
Object.keys(data.fonts || {}).forEach((key) => {
|
||||
if (!fontsKeys.has(key)) return
|
||||
if (!data.fonts[key]) return
|
||||
const originalFont = data.fonts[key]
|
||||
const originalFont = data.fonts[key].family
|
||||
const rule = { source: '2to3' }
|
||||
|
||||
switch (key) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue