better handling of logged-out state

This commit is contained in:
Henry Jameson 2026-08-14 19:38:37 +03:00
commit 55f5ae6a6c
9 changed files with 17 additions and 15 deletions

View file

@ -286,7 +286,7 @@ export const useStatusesStore = defineStore('statuses', {
// repeats stats can be incorrect based on polling condition, let's update them using the most recent data
newStatus.repeat_num = newStatus.rebloggedBy.length
newStatus.repeated = !!newStatus.rebloggedBy.find(
({ id }) => currentUser.id === id,
({ id }) => currentUser?.id === id,
)
},
addFavs({ id, favoritedByUsers }) {
@ -296,7 +296,7 @@ export const useStatusesStore = defineStore('statuses', {
// favorites stats can be incorrect based on polling condition, let's update them using the most recent data
newStatus.fave_num = newStatus.favoritedBy.length
newStatus.favorited = !!newStatus.favoritedBy.find(
({ id }) => currentUser.id === id,
({ id }) => currentUser?.id === id,
)
},
addEmojiReactionsBy({ id, emojiReactions }) {

View file

@ -96,7 +96,9 @@ export const useStreamingStore = defineStore('streaming', {
const { stream } = subscriber
this.subscribers.delete(subscriber)
this.subscriptions.get(stream.name).delete(stream.argument)
if (stream) {
this.subscriptions.get(stream.name).delete(stream.argument)
}
if (this.state === WSConnectionStatus.JOINED) {
this.socket.unsubscribe(...this.getSubArgs(stream))

View file

@ -190,7 +190,7 @@ export const useUsersStore = defineStore('users', {
this.usersByURL.set(user.url.toLowerCase(), reactive)
}
if (user.id === this.currentUser.id) {
if (user.id === this.currentUser?.id) {
this.currentUser = reactive
}
@ -647,11 +647,10 @@ export const useUsersStore = defineStore('users', {
})
.then(() => {
this.clearCurrentUser()
store.dispatch('stopFetchingNotifications')
useNotificationsStore().deactivate()
useListsStore().stopFetching()
useBookmarkFoldersStore().stopFetching()
store.dispatch('stopFetchingFollowRequests')
store.commit('clearNotifications')
useTimelinesStore().deactivateAll()
useStatusesStore().resetStatuses()
useNotificationsStore().clearNotifications()