forked from Mirrors/elk
feat: scroll to status (#127)
Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
parent
e51ca06f97
commit
5c60497421
3 changed files with 9 additions and 2 deletions
|
@ -38,7 +38,7 @@ const timeago = useTimeAgo(() => status.createdAt, timeAgoOptions)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="el" flex flex-col gap-2 px-4 transition-100 :class="{ 'hover:bg-active': hover }" tabindex="0" focus:outline-none focus-visible:ring="2 primary" @click="onclick" @keydown.enter="onclick">
|
<div :id="`status-${status.id}`" ref="el" flex flex-col gap-2 px-4 transition-100 :class="{ 'hover:bg-active': hover }" tabindex="0" focus:outline-none focus-visible:ring="2 primary" @click="onclick" @keydown.enter="onclick">
|
||||||
<div v-if="rebloggedBy" pl8>
|
<div v-if="rebloggedBy" pl8>
|
||||||
<div flex="~ wrap" gap-1 items-center text-gray:75 text-sm>
|
<div flex="~ wrap" gap-1 items-center text-gray:75 text-sm>
|
||||||
<div i-ri:repeat-fill mr-1 />
|
<div i-ri:repeat-fill mr-1 />
|
||||||
|
|
|
@ -17,7 +17,7 @@ const visibility = $computed(() => STATUS_VISIBILITIES.find(v => v.value === sta
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div flex flex-col gap-2 py3 px-4>
|
<div flex flex-col gap-2 py3 px-4 :id="`status-${status.id}`">
|
||||||
<AccountInfo :account="status.account" />
|
<AccountInfo :account="status.account" />
|
||||||
<StatusReplyingTo v-if="status.inReplyToAccountId" :status="status" />
|
<StatusReplyingTo v-if="status.inReplyToAccountId" :status="status" />
|
||||||
<StatusSpoiler :enabled="status.sensitive">
|
<StatusSpoiler :enabled="status.sensitive">
|
||||||
|
|
|
@ -7,6 +7,13 @@ const main = ref<Component | null>(null)
|
||||||
|
|
||||||
const status = window.history.state?.status ?? await fetchStatus(id)
|
const status = window.history.state?.status ?? await fetchStatus(id)
|
||||||
const { data: context } = useAsyncData(`context:${id}`, () => masto.statuses.fetchContext(id))
|
const { data: context } = useAsyncData(`context:${id}`, () => masto.statuses.fetchContext(id))
|
||||||
|
const unsubscribe = watch(context, async (context) => {
|
||||||
|
if (context) {
|
||||||
|
const statusElement = document.querySelector(`#status-${id}`)
|
||||||
|
statusElement?.scrollIntoView()
|
||||||
|
unsubscribe()
|
||||||
|
}
|
||||||
|
}, { flush: 'post' })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
Loading…
Reference in a new issue