conversation loading icon and errors

This commit is contained in:
uwaa 2025-01-24 05:27:51 +00:00
parent a29ac91125
commit 12430c90d6
3 changed files with 35 additions and 1 deletions

View file

@ -50,6 +50,7 @@ const sortAndFilterConversation = (conversation, statusoid) => {
const conversation = { const conversation = {
data () { data () {
return { return {
error: false,
highlight: null, highlight: null,
expanded: false, expanded: false,
threadDisplayStatusObject: {}, // id => 'showing' | 'hidden' threadDisplayStatusObject: {}, // id => 'showing' | 'hidden'
@ -380,6 +381,14 @@ const conversation = {
}, },
methods: { methods: {
fetchConversation () { fetchConversation () {
this.error = false
const displayError = (reason) => {
if (this.$store.state.users.currentUser) {
this.error = reason
} else {
this.error = this.$t('timeline.unauthorized')
}
}
if (this.status) { if (this.status) {
this.$store.state.api.backendInteractor.fetchConversation({ id: this.statusId }) this.$store.state.api.backendInteractor.fetchConversation({ id: this.statusId })
.then(({ ancestors, descendants }) => { .then(({ ancestors, descendants }) => {
@ -387,12 +396,14 @@ const conversation = {
this.$store.dispatch('addNewStatuses', { statuses: descendants }) this.$store.dispatch('addNewStatuses', { statuses: descendants })
this.setHighlight(this.originalStatusId) this.setHighlight(this.originalStatusId)
}) })
.catch(displayError)
} else { } else {
this.$store.state.api.backendInteractor.fetchStatus({ id: this.statusId }) this.$store.state.api.backendInteractor.fetchStatus({ id: this.statusId })
.then((status) => { .then((status) => {
this.$store.dispatch('addNewStatuses', { statuses: [status] }) this.$store.dispatch('addNewStatuses', { statuses: [status] })
this.fetchConversation() this.fetchConversation()
}) })
.catch(displayError)
} }
}, },
getReplies (id) { getReplies (id) {

View file

@ -18,7 +18,21 @@
{{ $t('timeline.collapse') }} {{ $t('timeline.collapse') }}
</button> </button>
</div> </div>
<div class="conversation-body panel-body"> <div
v-if="!error"
class="conversation-body panel-body"
>
<div
v-if="!status"
class="panel user-profile-placeholder"
>
<div class="panel-body">
<FAIcon
spin
icon="circle-notch"
/>
</div>
</div>
<div <div
v-if="isTreeView" v-if="isTreeView"
class="thread-body" class="thread-body"
@ -188,6 +202,14 @@
/> />
</div> </div>
</div> </div>
<div
v-else
class="panel user-profile-placeholder"
>
<div class="panel-body">
<span v-if="error">{{ error }}</span>
</div>
</div>
</div> </div>
<div <div
v-else v-else

View file

@ -1058,6 +1058,7 @@
"collapse": "Collapse", "collapse": "Collapse",
"conversation": "Conversation", "conversation": "Conversation",
"error": "Can't find the timeline: {0}", "error": "Can't find the timeline: {0}",
"unauthorized": "Please log in to view this status.",
"follow_tag": "Follow hashtag", "follow_tag": "Follow hashtag",
"load_older": "Load older posts", "load_older": "Load older posts",
"no_more_statuses": "No more posts", "no_more_statuses": "No more posts",