better handling of logged-out state
This commit is contained in:
parent
869e7cfe0f
commit
55f5ae6a6c
9 changed files with 17 additions and 15 deletions
|
|
@ -155,7 +155,7 @@ export default {
|
|||
]
|
||||
},
|
||||
userBackground() {
|
||||
return this.currentUser.background_image
|
||||
return this.currentUser?.background_image
|
||||
},
|
||||
foreignProfileBackground() {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ export default {
|
|||
},
|
||||
doLogout() {
|
||||
this.$router.replace('/main/public')
|
||||
this.$store.dispatch('logout')
|
||||
useUsersStore().logout()
|
||||
this.hideConfirmLogout()
|
||||
},
|
||||
onSearchBarToggled(hidden) {
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ const MobileNav = {
|
|||
},
|
||||
doLogout() {
|
||||
this.$router.replace('/main/public')
|
||||
this.$store.dispatch('logout')
|
||||
useUsersStore().logout()
|
||||
this.hideConfirmLogout()
|
||||
},
|
||||
markNotificationsAsSeen() {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ const SecurityTab = {
|
|||
password: this.deleteAccountConfirmPasswordInput,
|
||||
}).then(({ data: res }) => {
|
||||
if (res.status === 'success') {
|
||||
this.$store.dispatch('logout')
|
||||
useUsersStore().logout()
|
||||
this.$router.push({ name: 'root' })
|
||||
} else {
|
||||
this.deleteAccountError = res.error
|
||||
|
|
@ -172,7 +172,7 @@ const SecurityTab = {
|
|||
})
|
||||
},
|
||||
logout() {
|
||||
this.$store.dispatch('logout')
|
||||
useUsersStore().logout()
|
||||
this.$router.replace('/')
|
||||
},
|
||||
revokeToken(id) {
|
||||
|
|
|
|||
|
|
@ -299,11 +299,11 @@ const Status = {
|
|||
},
|
||||
muted() {
|
||||
if (this.ignoreMute) return false
|
||||
if (this.statusoid.user.id === this.currentUser.id) return false
|
||||
if (this.statusoid.user.id === this.currentUser?.id) return false
|
||||
return !this.unmuted && !this.shouldNotMute && this.muteReasons.length > 0
|
||||
},
|
||||
userIsMuted() {
|
||||
if (this.statusoid.user.id === this.currentUser.id) return false
|
||||
if (this.statusoid.user.id === this.currentUser?.id) return false
|
||||
const { status } = this
|
||||
const { reblog } = status
|
||||
const relationship = useUsersStore().relationship(status.user.id)
|
||||
|
|
|
|||
|
|
@ -35,9 +35,10 @@ export const BUTTONS = [
|
|||
name: 'retweet',
|
||||
label: ({ status }) =>
|
||||
status.repeated ? 'tool_tip.unrepeat' : 'tool_tip.repeat',
|
||||
icon({ status, currentUser }) {
|
||||
icon({ status, loggedIn, currentUser }) {
|
||||
if (
|
||||
currentUser.id !== status.user.id &&
|
||||
loggedIn &&
|
||||
status.user.id !== currentUser.id &&
|
||||
PRIVATE_SCOPES.has(status.visibility)
|
||||
) {
|
||||
return 'lock'
|
||||
|
|
|
|||
|
|
@ -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 }) {
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue