Compare commits
No commits in common. "6db351a5b0a98c9c9049a852eb79e931f4d59918" and "59c341347feb5026d712e976e47bec8bc97963d2" have entirely different histories.
6db351a5b0
...
59c341347f
1 changed files with 16 additions and 28 deletions
|
@ -237,11 +237,11 @@ const interfaceMod = {
|
||||||
} else if (themeName) {
|
} else if (themeName) {
|
||||||
promise = getPreset(themeName).then(themeData => normalizeThemeData(themeData))
|
promise = getPreset(themeName).then(themeData => normalizeThemeData(themeData))
|
||||||
} else if (userThemeSource || userThemeSnapshot) {
|
} else if (userThemeSource || userThemeSnapshot) {
|
||||||
promise = Promise.resolve(normalizeThemeData({
|
if (userThemeSource && userThemeSource.themeEngineVersion === CURRENT_VERSION) {
|
||||||
_pleroma_theme_version: 2,
|
promise = Promise.resolve(normalizeThemeData(userThemeSource))
|
||||||
theme: userThemeSnapshot,
|
} else {
|
||||||
source: userThemeSource
|
promise = Promise.resolve(normalizeThemeData(userThemeSnapshot))
|
||||||
}))
|
}
|
||||||
} else if (actualThemeName && actualThemeName !== 'custom') {
|
} else if (actualThemeName && actualThemeName !== 'custom') {
|
||||||
promise = getPreset(actualThemeName).then(themeData => {
|
promise = getPreset(actualThemeName).then(themeData => {
|
||||||
const realThemeData = normalizeThemeData(themeData)
|
const realThemeData = normalizeThemeData(themeData)
|
||||||
|
@ -355,8 +355,10 @@ const interfaceMod = {
|
||||||
export default interfaceMod
|
export default interfaceMod
|
||||||
|
|
||||||
export const normalizeThemeData = (input) => {
|
export const normalizeThemeData = (input) => {
|
||||||
if (Array.isArray(input)) {
|
let themeData = input
|
||||||
const themeData = { colors: {} }
|
|
||||||
|
if (Array.isArray(themeData)) {
|
||||||
|
themeData = { colors: {} }
|
||||||
themeData.colors.bg = input[1]
|
themeData.colors.bg = input[1]
|
||||||
themeData.colors.fg = input[2]
|
themeData.colors.fg = input[2]
|
||||||
themeData.colors.text = input[3]
|
themeData.colors.text = input[3]
|
||||||
|
@ -368,32 +370,18 @@ export const normalizeThemeData = (input) => {
|
||||||
return generatePreset(themeData).theme
|
return generatePreset(themeData).theme
|
||||||
}
|
}
|
||||||
|
|
||||||
let themeData, themeSource
|
if (themeData.themeFileVerison === 1) {
|
||||||
|
return generatePreset(themeData).theme
|
||||||
if (input.themeFileVerison === 1) {
|
|
||||||
// this might not be even used at all, some leftover of unimplemented code in V2 editor
|
|
||||||
return generatePreset(input).theme
|
|
||||||
} else if (
|
|
||||||
Object.prototype.hasOwnProperty.call(input, '_pleroma_theme_version') ||
|
|
||||||
Object.prototype.hasOwnProperty.call(input, 'source') ||
|
|
||||||
Object.prototype.hasOwnProperty.call(input, 'theme')
|
|
||||||
) {
|
|
||||||
// We got passed a full theme file
|
|
||||||
themeData = input.theme
|
|
||||||
themeSource = input.source
|
|
||||||
} else if (Object.prototype.hasOwnProperty.call(input, 'themeEngineVersion')) {
|
|
||||||
// We got passed a source/snapshot
|
|
||||||
themeData = input
|
|
||||||
themeSource = input
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New theme presets don't have 'theme' property, they use 'source'
|
// New theme presets don't have 'theme' property, they use 'source'
|
||||||
|
const themeSource = themeData.source
|
||||||
|
|
||||||
let out // shout, shout let it all out
|
let out // shout, shout let it all out
|
||||||
if (themeSource && themeSource.themeEngineVersion === CURRENT_VERSION) {
|
if (!themeData.theme || (themeSource && themeSource.themeEngineVersion === CURRENT_VERSION)) {
|
||||||
// There are some themes in wild that have completely broken source
|
out = themeSource || themeData
|
||||||
out = { ...(themeData || {}), ...themeSource }
|
|
||||||
} else {
|
} else {
|
||||||
out = themeData
|
out = themeData.theme
|
||||||
}
|
}
|
||||||
|
|
||||||
// generatePreset here basically creates/updates "snapshot",
|
// generatePreset here basically creates/updates "snapshot",
|
||||||
|
|
Loading…
Add table
Reference in a new issue