don't normalize theme and split index fetching into its own block
This commit is contained in:
parent
541affd459
commit
48cc7ccc78
|
@ -220,7 +220,8 @@ const interfaceMod = {
|
||||||
return value
|
return value
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Could not fetch palettes index', e)
|
console.error('Could not fetch palettes index', e)
|
||||||
return {}
|
commit('setInstanceOption', { name: 'palettesIndex', value: { _error: e } })
|
||||||
|
return Promise.resolve({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setPalette ({ dispatch, commit }, value) {
|
setPalette ({ dispatch, commit }, value) {
|
||||||
|
@ -246,6 +247,7 @@ const interfaceMod = {
|
||||||
return value
|
return value
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Could not fetch styles index', e)
|
console.error('Could not fetch styles index', e)
|
||||||
|
commit('setInstanceOption', { name: 'stylesIndex', value: { _error: e } })
|
||||||
return Promise.resolve({})
|
return Promise.resolve({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -272,6 +274,7 @@ const interfaceMod = {
|
||||||
return value
|
return value
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Could not fetch themes index', e)
|
console.error('Could not fetch themes index', e)
|
||||||
|
commit('setInstanceOption', { name: 'themesIndex', value: { _error: e } })
|
||||||
return Promise.resolve({})
|
return Promise.resolve({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -374,29 +377,33 @@ const interfaceMod = {
|
||||||
userThemeV2Snapshot = null
|
userThemeV2Snapshot = null
|
||||||
|
|
||||||
majorVersionUsed = 'v3'
|
majorVersionUsed = 'v3'
|
||||||
if (!palettesIndex || !stylesIndex) {
|
|
||||||
const result = await Promise.all([
|
|
||||||
dispatch('fetchPalettesIndex'),
|
|
||||||
dispatch('fetchStylesIndex')
|
|
||||||
])
|
|
||||||
|
|
||||||
palettesIndex = result[0]
|
|
||||||
stylesIndex = result[1]
|
|
||||||
}
|
|
||||||
} else if (
|
} else if (
|
||||||
userThemeV2Name ||
|
(userThemeV2Name ||
|
||||||
userThemeV2Snapshot ||
|
userThemeV2Snapshot ||
|
||||||
userThemeV2Source ||
|
userThemeV2Source ||
|
||||||
instanceThemeV2Name
|
instanceThemeV2Name)
|
||||||
) {
|
) {
|
||||||
majorVersionUsed = 'v2'
|
majorVersionUsed = 'v2'
|
||||||
|
} else {
|
||||||
|
// if all fails fallback to v3
|
||||||
|
majorVersionUsed = 'v3'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (majorVersionUsed === 'v3') {
|
||||||
|
const result = await Promise.all([
|
||||||
|
dispatch('fetchPalettesIndex'),
|
||||||
|
dispatch('fetchStylesIndex')
|
||||||
|
])
|
||||||
|
|
||||||
|
palettesIndex = result[0]
|
||||||
|
stylesIndex = result[1]
|
||||||
|
} else {
|
||||||
// Promise.all just to be uniform with v3
|
// Promise.all just to be uniform with v3
|
||||||
const result = await Promise.all([
|
const result = await Promise.all([
|
||||||
dispatch('fetchThemesIndex')
|
dispatch('fetchThemesIndex')
|
||||||
])
|
])
|
||||||
|
|
||||||
themesIndex = result[0]
|
themesIndex = result[0]
|
||||||
} else {
|
|
||||||
majorVersionUsed = 'v3'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state.themeVersion = majorVersionUsed
|
state.themeVersion = majorVersionUsed
|
||||||
|
@ -483,7 +490,7 @@ const interfaceMod = {
|
||||||
userThemeV2Name || instanceThemeV2Name
|
userThemeV2Name || instanceThemeV2Name
|
||||||
)
|
)
|
||||||
themeNameUsed = theme.nameUsed
|
themeNameUsed = theme.nameUsed
|
||||||
themeDataUsed = { ...theme.dataUsed, themeEngineVersion: CURRENT_VERSION }
|
themeDataUsed = theme.dataUsed
|
||||||
|
|
||||||
// Themes v2 editor support
|
// Themes v2 editor support
|
||||||
commit('setInstanceOption', { name: 'themeData', value: themeDataUsed })
|
commit('setInstanceOption', { name: 'themeData', value: themeDataUsed })
|
||||||
|
@ -523,7 +530,7 @@ const interfaceMod = {
|
||||||
return result
|
return result
|
||||||
})()
|
})()
|
||||||
|
|
||||||
const theme2ruleset = themeDataUsed && convertTheme2To3(normalizeThemeData(themeDataUsed))
|
const theme2ruleset = themeDataUsed && convertTheme2To3(generatePreset(themeDataUsed).source)
|
||||||
const hacks = []
|
const hacks = []
|
||||||
|
|
||||||
Object.entries(theme3hacks).forEach(([key, value]) => {
|
Object.entries(theme3hacks).forEach(([key, value]) => {
|
||||||
|
|
Loading…
Reference in a new issue