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() {
|
userBackground() {
|
||||||
return this.currentUser.background_image
|
return this.currentUser?.background_image
|
||||||
},
|
},
|
||||||
foreignProfileBackground() {
|
foreignProfileBackground() {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ export default {
|
||||||
},
|
},
|
||||||
doLogout() {
|
doLogout() {
|
||||||
this.$router.replace('/main/public')
|
this.$router.replace('/main/public')
|
||||||
this.$store.dispatch('logout')
|
useUsersStore().logout()
|
||||||
this.hideConfirmLogout()
|
this.hideConfirmLogout()
|
||||||
},
|
},
|
||||||
onSearchBarToggled(hidden) {
|
onSearchBarToggled(hidden) {
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ const MobileNav = {
|
||||||
},
|
},
|
||||||
doLogout() {
|
doLogout() {
|
||||||
this.$router.replace('/main/public')
|
this.$router.replace('/main/public')
|
||||||
this.$store.dispatch('logout')
|
useUsersStore().logout()
|
||||||
this.hideConfirmLogout()
|
this.hideConfirmLogout()
|
||||||
},
|
},
|
||||||
markNotificationsAsSeen() {
|
markNotificationsAsSeen() {
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ const SecurityTab = {
|
||||||
password: this.deleteAccountConfirmPasswordInput,
|
password: this.deleteAccountConfirmPasswordInput,
|
||||||
}).then(({ data: res }) => {
|
}).then(({ data: res }) => {
|
||||||
if (res.status === 'success') {
|
if (res.status === 'success') {
|
||||||
this.$store.dispatch('logout')
|
useUsersStore().logout()
|
||||||
this.$router.push({ name: 'root' })
|
this.$router.push({ name: 'root' })
|
||||||
} else {
|
} else {
|
||||||
this.deleteAccountError = res.error
|
this.deleteAccountError = res.error
|
||||||
|
|
@ -172,7 +172,7 @@ const SecurityTab = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
this.$store.dispatch('logout')
|
useUsersStore().logout()
|
||||||
this.$router.replace('/')
|
this.$router.replace('/')
|
||||||
},
|
},
|
||||||
revokeToken(id) {
|
revokeToken(id) {
|
||||||
|
|
|
||||||
|
|
@ -299,11 +299,11 @@ const Status = {
|
||||||
},
|
},
|
||||||
muted() {
|
muted() {
|
||||||
if (this.ignoreMute) return false
|
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
|
return !this.unmuted && !this.shouldNotMute && this.muteReasons.length > 0
|
||||||
},
|
},
|
||||||
userIsMuted() {
|
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 { status } = this
|
||||||
const { reblog } = status
|
const { reblog } = status
|
||||||
const relationship = useUsersStore().relationship(status.user.id)
|
const relationship = useUsersStore().relationship(status.user.id)
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,10 @@ export const BUTTONS = [
|
||||||
name: 'retweet',
|
name: 'retweet',
|
||||||
label: ({ status }) =>
|
label: ({ status }) =>
|
||||||
status.repeated ? 'tool_tip.unrepeat' : 'tool_tip.repeat',
|
status.repeated ? 'tool_tip.unrepeat' : 'tool_tip.repeat',
|
||||||
icon({ status, currentUser }) {
|
icon({ status, loggedIn, currentUser }) {
|
||||||
if (
|
if (
|
||||||
currentUser.id !== status.user.id &&
|
loggedIn &&
|
||||||
|
status.user.id !== currentUser.id &&
|
||||||
PRIVATE_SCOPES.has(status.visibility)
|
PRIVATE_SCOPES.has(status.visibility)
|
||||||
) {
|
) {
|
||||||
return 'lock'
|
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
|
// 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.repeat_num = newStatus.rebloggedBy.length
|
||||||
newStatus.repeated = !!newStatus.rebloggedBy.find(
|
newStatus.repeated = !!newStatus.rebloggedBy.find(
|
||||||
({ id }) => currentUser.id === id,
|
({ id }) => currentUser?.id === id,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
addFavs({ id, favoritedByUsers }) {
|
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
|
// 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.fave_num = newStatus.favoritedBy.length
|
||||||
newStatus.favorited = !!newStatus.favoritedBy.find(
|
newStatus.favorited = !!newStatus.favoritedBy.find(
|
||||||
({ id }) => currentUser.id === id,
|
({ id }) => currentUser?.id === id,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
addEmojiReactionsBy({ id, emojiReactions }) {
|
addEmojiReactionsBy({ id, emojiReactions }) {
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,9 @@ export const useStreamingStore = defineStore('streaming', {
|
||||||
const { stream } = subscriber
|
const { stream } = subscriber
|
||||||
|
|
||||||
this.subscribers.delete(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) {
|
if (this.state === WSConnectionStatus.JOINED) {
|
||||||
this.socket.unsubscribe(...this.getSubArgs(stream))
|
this.socket.unsubscribe(...this.getSubArgs(stream))
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ export const useUsersStore = defineStore('users', {
|
||||||
this.usersByURL.set(user.url.toLowerCase(), reactive)
|
this.usersByURL.set(user.url.toLowerCase(), reactive)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.id === this.currentUser.id) {
|
if (user.id === this.currentUser?.id) {
|
||||||
this.currentUser = reactive
|
this.currentUser = reactive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -647,11 +647,10 @@ export const useUsersStore = defineStore('users', {
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.clearCurrentUser()
|
this.clearCurrentUser()
|
||||||
store.dispatch('stopFetchingNotifications')
|
useNotificationsStore().deactivate()
|
||||||
useListsStore().stopFetching()
|
useListsStore().stopFetching()
|
||||||
useBookmarkFoldersStore().stopFetching()
|
useBookmarkFoldersStore().stopFetching()
|
||||||
store.dispatch('stopFetchingFollowRequests')
|
store.dispatch('stopFetchingFollowRequests')
|
||||||
store.commit('clearNotifications')
|
|
||||||
useTimelinesStore().deactivateAll()
|
useTimelinesStore().deactivateAll()
|
||||||
useStatusesStore().resetStatuses()
|
useStatusesStore().resetStatuses()
|
||||||
useNotificationsStore().clearNotifications()
|
useNotificationsStore().clearNotifications()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue