Disable push notifications when logging out of instance
nolanlawson opened this issue · 0 comments
nolanlawson commented
As far as I can tell, we don't unsubscribe from push notifications when you log out of an instance:
pinafore/src/routes/_actions/instances.js
Lines 36 to 88 in 97e3b04
export async function logOutOfInstance (instanceName, message) { | |
message = message || formatIntl('intl.loggedOutOfInstance', { instance: instanceName }) | |
const { | |
composeData, | |
currentInstance, | |
customEmoji, | |
instanceInfos, | |
instanceLists, | |
instanceThemes, | |
loggedInInstances, | |
loggedInInstancesInOrder, | |
verifyCredentials | |
} = store.get() | |
loggedInInstancesInOrder.splice(loggedInInstancesInOrder.indexOf(instanceName), 1) | |
const newInstance = instanceName === currentInstance ? loggedInInstancesInOrder[0] : currentInstance | |
const objectsToClear = [ | |
composeData, | |
customEmoji, | |
instanceInfos, | |
instanceLists, | |
instanceThemes, | |
loggedInInstances, | |
verifyCredentials | |
] | |
for (const obj of objectsToClear) { | |
delete obj[instanceName] | |
} | |
store.set({ | |
composeData, | |
currentInstance: newInstance, | |
customEmoji, | |
instanceInfos, | |
instanceLists, | |
instanceThemes, | |
loggedInInstances, | |
loggedInInstancesInOrder, | |
queryInSearch: '', | |
searchResults: null, | |
timelineInitialized: false, | |
timelinePreinitialized: false, | |
verifyCredentials | |
}) | |
store.clearTimelineDataForInstance(instanceName) | |
store.clearAutosuggestDataForInstance(instanceName) | |
store.save() | |
const { virtualListStore } = await importVirtualListStore() | |
virtualListStore.clearRealmByPrefix(currentInstance + '/') // TODO: this is a hacky way to clear the vlist cache | |
toast.say(message) | |
const { enableGrayscale } = store.get() | |
switchToTheme(instanceThemes[newInstance], enableGrayscale) | |
/* no await */ database.clearDatabaseForInstance(instanceName) | |
goto('/settings/instances') | |
} |
I'm surprised we haven't gotten a bug about this, though, so I could be wrong. Maybe it "just works" somehow already.