fixes, clear cache on logout
This commit is contained in:
parent
c3e7eadddf
commit
8d3d8fffab
|
@ -95,7 +95,7 @@ const NavPanel = {
|
||||||
{
|
{
|
||||||
hasChats: this.pleromaChatMessagesAvailable,
|
hasChats: this.pleromaChatMessagesAvailable,
|
||||||
isFederating: this.federating,
|
isFederating: this.federating,
|
||||||
isPrivate: this.private,
|
isPrivate: this.privateMode,
|
||||||
currentUser: this.currentUser
|
currentUser: this.currentUser
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -108,7 +108,7 @@ const NavPanel = {
|
||||||
{
|
{
|
||||||
hasChats: this.pleromaChatMessagesAvailable,
|
hasChats: this.pleromaChatMessagesAvailable,
|
||||||
isFederating: this.federating,
|
isFederating: this.federating,
|
||||||
isPrivate: this.private,
|
isPrivate: this.privateMode,
|
||||||
currentUser: this.currentUser
|
currentUser: this.currentUser
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,6 +16,7 @@ const NavigationEntry = {
|
||||||
} else {
|
} else {
|
||||||
this.$store.commit('addCollectionPreference', { path: 'collections.pinnedNavItems', value })
|
this.$store.commit('addCollectionPreference', { path: 'collections.pinnedNavItems', value })
|
||||||
}
|
}
|
||||||
|
this.$store.dispatch('pushServerSideStorage')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -64,7 +64,7 @@ const NavPanel = {
|
||||||
{
|
{
|
||||||
hasChats: this.pleromaChatMessagesAvailable,
|
hasChats: this.pleromaChatMessagesAvailable,
|
||||||
isFederating: this.federating,
|
isFederating: this.federating,
|
||||||
isPrivate: this.private,
|
isPrivate: this.privateMode,
|
||||||
currentUser: this.currentUser
|
currentUser: this.currentUser
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -51,8 +51,9 @@ export const _moveItemInArray = (array, value, movement) => {
|
||||||
return newArray
|
return newArray
|
||||||
}
|
}
|
||||||
|
|
||||||
const _wrapData = (data) => ({
|
const _wrapData = (data, userName) => ({
|
||||||
...data,
|
...data,
|
||||||
|
_user: userName,
|
||||||
_timestamp: Date.now(),
|
_timestamp: Date.now(),
|
||||||
_version: VERSION
|
_version: VERSION
|
||||||
})
|
})
|
||||||
|
@ -254,10 +255,17 @@ export const _doMigrations = (cache) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
|
clearServerSideStorage (state, userData) {
|
||||||
|
state = { ...cloneDeep(defaultState) }
|
||||||
|
},
|
||||||
setServerSideStorage (state, userData) {
|
setServerSideStorage (state, userData) {
|
||||||
const live = userData.storage
|
const live = userData.storage
|
||||||
state.raw = live
|
state.raw = live
|
||||||
let cache = state.cache
|
let cache = state.cache
|
||||||
|
if (cache._user !== userData.fqn) {
|
||||||
|
console.warn('cache belongs to another user! reinitializing local cache!')
|
||||||
|
cache = null
|
||||||
|
}
|
||||||
|
|
||||||
cache = _doMigrations(cache)
|
cache = _doMigrations(cache)
|
||||||
|
|
||||||
|
@ -371,12 +379,12 @@ export const mutations = {
|
||||||
]
|
]
|
||||||
state.dirty = true
|
state.dirty = true
|
||||||
},
|
},
|
||||||
updateCache (state) {
|
updateCache (state, { username }) {
|
||||||
state.prefsStorage._journal = _mergeJournal(state.prefsStorage._journal)
|
state.prefsStorage._journal = _mergeJournal(state.prefsStorage._journal)
|
||||||
state.cache = _wrapData({
|
state.cache = _wrapData({
|
||||||
flagStorage: toRaw(state.flagStorage),
|
flagStorage: toRaw(state.flagStorage),
|
||||||
prefsStorage: toRaw(state.prefsStorage)
|
prefsStorage: toRaw(state.prefsStorage)
|
||||||
})
|
}, username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,8 +396,9 @@ const serverSideStorage = {
|
||||||
actions: {
|
actions: {
|
||||||
pushServerSideStorage ({ state, rootState, commit }, { force = false } = {}) {
|
pushServerSideStorage ({ state, rootState, commit }, { force = false } = {}) {
|
||||||
const needPush = state.dirty || force
|
const needPush = state.dirty || force
|
||||||
|
console.log(needPush)
|
||||||
if (!needPush) return
|
if (!needPush) return
|
||||||
commit('updateCache')
|
commit('updateCache', { username: rootState.users.currentUser.fqn })
|
||||||
const params = { pleroma_settings_store: { 'pleroma-fe': state.cache } }
|
const params = { pleroma_settings_store: { 'pleroma-fe': state.cache } }
|
||||||
rootState.api.backendInteractor
|
rootState.api.backendInteractor
|
||||||
.updateProfile({ params })
|
.updateProfile({ params })
|
||||||
|
|
|
@ -509,6 +509,7 @@ const users = {
|
||||||
store.dispatch('setLastTimeline', 'public-timeline')
|
store.dispatch('setLastTimeline', 'public-timeline')
|
||||||
store.dispatch('setLayoutWidth', windowWidth())
|
store.dispatch('setLayoutWidth', windowWidth())
|
||||||
store.dispatch('setLayoutHeight', windowHeight())
|
store.dispatch('setLayoutHeight', windowHeight())
|
||||||
|
store.commit('clearServerSideStorage')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loginUser (store, accessToken) {
|
loginUser (store, accessToken) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ export const parseUser = (data) => {
|
||||||
|
|
||||||
if (masto) {
|
if (masto) {
|
||||||
output.screen_name = data.acct
|
output.screen_name = data.acct
|
||||||
|
output.fqn = data.fqn
|
||||||
output.statusnet_profile_url = data.url
|
output.statusnet_profile_url = data.url
|
||||||
|
|
||||||
// There's nothing else to get
|
// There's nothing else to get
|
||||||
|
|
|
@ -127,7 +127,7 @@ describe('The serverSideStorage module', () => {
|
||||||
const state = cloneDeep(defaultState)
|
const state = cloneDeep(defaultState)
|
||||||
setPreference(state, { path: 'simple.testing', value: 1 })
|
setPreference(state, { path: 'simple.testing', value: 1 })
|
||||||
setPreference(state, { path: 'simple.testing', value: 2 })
|
setPreference(state, { path: 'simple.testing', value: 2 })
|
||||||
updateCache(state)
|
updateCache(state, { username: 'test' })
|
||||||
expect(state.prefsStorage.simple.testing).to.eql(2)
|
expect(state.prefsStorage.simple.testing).to.eql(2)
|
||||||
expect(state.prefsStorage._journal.length).to.eql(1)
|
expect(state.prefsStorage._journal.length).to.eql(1)
|
||||||
expect(state.prefsStorage._journal[0]).to.eql({
|
expect(state.prefsStorage._journal[0]).to.eql({
|
||||||
|
|
Loading…
Reference in New Issue