Fix getting post from parents timeline

Signed-off-by: Louis Chemineau <louis@chmn.me>
pull/1696/head
Louis Chemineau 2023-03-22 18:50:20 +01:00
rodzic 609f704464
commit ea7015ef4f
2 zmienionych plików z 15 dodań i 18 usunięć

Wyświetl plik

@ -184,8 +184,10 @@ const getters = {
},
getPostFromTimeline(state) {
return (postId) => {
if (typeof state.timeline[postId] !== 'undefined') {
if (state.timeline[postId] !== undefined) {
return state.timeline[postId]
} else if (state.parentsTimeline[postId] !== undefined) {
return state.parentsTimeline[postId]
} else {
logger.warn('Could not find post in timeline', { postId })
}

Wyświetl plik

@ -63,29 +63,24 @@ export default {
return this.$store.getters.getTimeline
},
},
beforeMount() {
// Get data of post clicked on
async beforeMount() {
this.mainPost = this.$store.getters.getPostFromTimeline(this.$route.params.id) || loadState('social', 'item')
// Fetch information of the related account
this.$store.dispatch(this.serverData.public ? 'fetchPublicAccountInfo' : 'fetchAccountInfo', this.account).then((response) => {
// We need to update this.uid because we may have asked info for an account whose domain part was a host-meta,
// and the account returned by the backend always uses a non host-meta'ed domain for its ID
this.uid = response.username
})
// Fetch single post timeline
const params = {
account: this.account,
id: this.$route.params.id,
type: 'single-post',
}
this.$store.dispatch('changeTimelineType', {
type: 'single-post',
params,
params: {
account: this.account,
id: this.$route.params.id,
type: 'single-post',
},
})
},
methods: {
// Fetch information of the related account
const response = await this.$store.dispatch(this.serverData.public ? 'fetchPublicAccountInfo' : 'fetchAccountInfo', this.account)
// We need to update this.uid because we may have asked info for an account whose domain part was a host-meta,
// and the account returned by the backend always uses a non host-meta'ed domain for its ID
this.uid = response.username
},
}
</script>