revert interface.js since it's an action it will be always asynchronous
This commit is contained in:
parent
6c6d356f70
commit
d2f85f4f25
|
@ -56,6 +56,9 @@ const interfaceMod = {
|
||||||
state.temporaryChangesConfirm = () => {}
|
state.temporaryChangesConfirm = () => {}
|
||||||
state.temporaryChangesRevert = () => {}
|
state.temporaryChangesRevert = () => {}
|
||||||
},
|
},
|
||||||
|
setThemeApplied (state) {
|
||||||
|
state.themeApplied = true
|
||||||
|
},
|
||||||
setNotificationPermission (state, permission) {
|
setNotificationPermission (state, permission) {
|
||||||
state.notificationPermission = permission
|
state.notificationPermission = permission
|
||||||
},
|
},
|
||||||
|
@ -117,9 +120,6 @@ const interfaceMod = {
|
||||||
setPageTitle ({ rootState }, option = '') {
|
setPageTitle ({ rootState }, option = '') {
|
||||||
document.title = `${option} ${rootState.instance.name}`
|
document.title = `${option} ${rootState.instance.name}`
|
||||||
},
|
},
|
||||||
setThemeApplied ({ state, rootGetters }) {
|
|
||||||
state.themeApplied = true
|
|
||||||
},
|
|
||||||
settingsSaved ({ commit, dispatch }, { success, error }) {
|
settingsSaved ({ commit, dispatch }, { success, error }) {
|
||||||
commit('settingsSaved', { success, error })
|
commit('settingsSaved', { success, error })
|
||||||
},
|
},
|
||||||
|
@ -212,7 +212,7 @@ const interfaceMod = {
|
||||||
setLastTimeline ({ commit }, value) {
|
setLastTimeline ({ commit }, value) {
|
||||||
commit('setLastTimeline', value)
|
commit('setLastTimeline', value)
|
||||||
},
|
},
|
||||||
setTheme ({ dispatch, commit, rootState }, { themeName, themeData, recompile, saveData } = {}) {
|
setTheme ({ commit, rootState }, { themeName, themeData, recompile, saveData } = {}) {
|
||||||
const {
|
const {
|
||||||
theme: instanceThemeName
|
theme: instanceThemeName
|
||||||
} = rootState.instance
|
} = rootState.instance
|
||||||
|
@ -230,27 +230,27 @@ const interfaceMod = {
|
||||||
|
|
||||||
const forceRecompile = forceThemeRecompilation || recompile
|
const forceRecompile = forceThemeRecompilation || recompile
|
||||||
|
|
||||||
let result = null
|
let promise = null
|
||||||
|
|
||||||
if (themeData) {
|
if (themeData) {
|
||||||
result = normalizeThemeData(themeData)
|
promise = Promise.resolve(normalizeThemeData(themeData))
|
||||||
} else if (themeName) {
|
} else if (themeName) {
|
||||||
result = normalizeThemeData(getPreset(themeName))
|
promise = getPreset(themeName).then(themeData => normalizeThemeData(themeData))
|
||||||
.then(themeData => normalizeThemeData(themeData))
|
|
||||||
} else if (userThemeSource || userThemeSnapshot) {
|
} else if (userThemeSource || userThemeSnapshot) {
|
||||||
result = normalizeThemeData({
|
promise = Promise.resolve(normalizeThemeData({
|
||||||
_pleroma_theme_version: 2,
|
_pleroma_theme_version: 2,
|
||||||
theme: userThemeSnapshot,
|
theme: userThemeSnapshot,
|
||||||
source: userThemeSource
|
source: userThemeSource
|
||||||
})
|
}))
|
||||||
} else if (actualThemeName && actualThemeName !== 'custom') {
|
} else if (actualThemeName && actualThemeName !== 'custom') {
|
||||||
const themeData = getPreset(actualThemeName)
|
promise = getPreset(actualThemeName).then(themeData => {
|
||||||
const realThemeData = normalizeThemeData(themeData)
|
const realThemeData = normalizeThemeData(themeData)
|
||||||
if (actualThemeName === instanceThemeName) {
|
if (actualThemeName === instanceThemeName) {
|
||||||
// This sole line is the reason why this whole block is above the recompilation check
|
// This sole line is the reason why this whole block is above the recompilation check
|
||||||
commit('setInstanceOption', { name: 'themeData', value: { theme: realThemeData } })
|
commit('setInstanceOption', { name: 'themeData', value: { theme: realThemeData } })
|
||||||
}
|
}
|
||||||
result = realThemeData
|
return realThemeData
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Cannot load any theme!')
|
throw new Error('Cannot load any theme!')
|
||||||
}
|
}
|
||||||
|
@ -258,10 +258,12 @@ const interfaceMod = {
|
||||||
// If we're not not forced to recompile try using
|
// If we're not not forced to recompile try using
|
||||||
// cache (tryLoadCache return true if load successful)
|
// cache (tryLoadCache return true if load successful)
|
||||||
if (!forceRecompile && !themeDebug && tryLoadCache()) {
|
if (!forceRecompile && !themeDebug && tryLoadCache()) {
|
||||||
return dispatch('setThemeApplied')
|
commit('setThemeApplied')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const realThemeData = result
|
promise
|
||||||
|
.then(realThemeData => {
|
||||||
const theme2ruleset = convertTheme2To3(realThemeData)
|
const theme2ruleset = convertTheme2To3(realThemeData)
|
||||||
|
|
||||||
if (saveData) {
|
if (saveData) {
|
||||||
|
@ -340,9 +342,12 @@ const interfaceMod = {
|
||||||
|
|
||||||
applyTheme(
|
applyTheme(
|
||||||
ruleset,
|
ruleset,
|
||||||
() => dispatch('setThemeApplied'),
|
() => commit('setThemeApplied'),
|
||||||
themeDebug
|
themeDebug
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
return promise
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue