forgot this one
This commit is contained in:
parent
15fe1b9c32
commit
ad8519e0f3
1 changed files with 24 additions and 0 deletions
24
src/composables/useMainStatus.js
Normal file
24
src/composables/useMainStatus.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { computed, toValue } from 'vue'
|
||||||
|
|
||||||
|
import { useStatusesStore } from 'src/stores/statuses.js'
|
||||||
|
|
||||||
|
export function useMainStatus(statusId) {
|
||||||
|
const getStatusObject = (id) => useStatusesStore().allStatuses.get(id)
|
||||||
|
|
||||||
|
const status = computed(() => getStatusObject(toValue(statusId)))
|
||||||
|
|
||||||
|
const mainStatus = computed(() => {
|
||||||
|
if (!status.value) return
|
||||||
|
const retweetedStatusId = status.value.retweeted_status?.id
|
||||||
|
if (retweetedStatusId) {
|
||||||
|
return getStatusObject(retweetedStatusId)
|
||||||
|
} else {
|
||||||
|
return status.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
status,
|
||||||
|
mainStatus,
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue