diff --git a/src/api/public.js b/src/api/public.js index 839196b9e..7e109e297 100644 --- a/src/api/public.js +++ b/src/api/public.js @@ -25,7 +25,8 @@ export const MASTODON_FOLLOWERS_URL = ( `/api/v1/accounts/${id}/followers${paramsString({ minId, maxId, sinceId, limit, withRelationships })}` export const MASTODON_STATUS_URL = (id) => `/api/v1/statuses/${id}` -const MASTODON_STATUS_CONTEXT_URL = (id) => `/api/v1/statuses/${id}/context` +export const MASTODON_STATUS_CONTEXT_URL = (id) => + `/api/v1/statuses/${id}/context` export const MASTODON_STATUS_SOURCE_URL = (id) => `/api/v1/statuses/${id}/source` export const MASTODON_STATUS_HISTORY_URL = (id) => diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 9855c01cd..b0d116341 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -1,15 +1,14 @@ import { storeToRefs } from 'pinia' import { computed, + nextTick, onUnmounted, provide, ref, toRefs, useTemplateRef, watch, - nextTick, } from 'vue' -import { useRouter } from 'vue-router' import ChatMessageList from 'src/components/chat_message_list/chat_message_list.vue' import PostStatusForm from 'src/components/post_status_form/post_status_form.vue' @@ -68,7 +67,6 @@ export default { }, emits: ['heightChange', 'suspendableStateChange', 'expanded', 'collapsed'], setup(props, { emit }) { - const router = useRouter() const scroller = useScrollPosition() const { statusId } = toRefs(props) @@ -97,7 +95,9 @@ export default { provide('isExpanded', isExpanded) provide('isPage', isPage) provide('expandable', true) - watch(expanded, (val) => val ? emit('expanded') : emit('collapsed'), { flush: 'post' }) + watch(expanded, (val) => (val ? emit('expanded') : emit('collapsed')), { + flush: 'post', + }) // # Main things const { @@ -105,7 +105,6 @@ export default { conversationId, setFocused, currentStatus, - mainStatus, conversation, replies, getReplies, @@ -115,17 +114,9 @@ export default { const conversationLite = computed(() => conversation.value.map(({ id }) => ({ id })), ) - const mainStatusId = computed(() => mainStatus.value.id) - - watch( - expanded, - (value) => { - if (value) { - fetchConversation() - } - }, - { flush: 'post' }, - ) + provide('focusedId', focusedId) + provide('conversation', conversation) + provide('replies', replies) // Component created if (isPage.value) { @@ -149,7 +140,7 @@ export default { return result } - // External virtual scrolling + // # External virtual scrolling const unsuspendableIds = ref(new Set()) const suspendable = computed( () => !isExpanded.value && unsuspendableIds.value.size === 0, @@ -176,32 +167,30 @@ export default { emit('suspendableStateChange', { suspend: value, id: statusId.value }), ) onUnmounted(() => resizeObserver.value.disconnect()) - // Internal virtual scrolling + + // # Internal virtual scrolling const virtualScrollingEnabled = ref(isExpanded.value) // Placeholder heights. const { fontSize, navbarSize, panelHeaderSize } = useInterfaceSizes() - const mutedStatusHeight = computed(() => fontSize.value * 1.5) const normalStatusHeight = computed(() => fontSize.value * 10) - const getPlaceholderHeight = (id) => - conversation.value.find((item) => item.id === id)?.muted - ? mutedStatusHeight - : normalStatusHeight + const getPlaceholderHeight = (id) => normalStatusHeight const offset = computed(() => { // The fontsize after navbar is the little gap between navbar and content if (isPage.value) { return navbarSize.value + fontSize.value + panelHeaderSize.value } else if (expanded.value) { - return navbarSize.value + fontSize.value + panelHeaderSize.value * 2 + rootElementMargin.value + return ( + navbarSize.value + + fontSize.value + + panelHeaderSize.value * 2 + + rootElementMargin.value + ) } else { return navbarSize.value + fontSize.value } }) - const anchorIds = computed( - () => new Set([mainStatus.value?.id, currentStatus.value?.id]), - ) - // # Linear style stuff const isLinearView = computed(() => displayStyle.value !== 'tree') const linearElement = useTemplateRef('linear') @@ -222,8 +211,6 @@ export default { offset, scrollPositionInstance: scroller, scrollCompensation: linearScrollCompensation, - anchorIds, - collapseMode: 'item', getPlaceholderHeight, }) const changeSuspendStateLinearLocal = (e) => { @@ -301,7 +288,6 @@ export default { resetTreeScrollVirtualization() }) - const treeViewIsSimple = computed( () => !mergedConfig.value.conversationTreeAdvanced, ) @@ -318,8 +304,8 @@ export default { return linearScrollTo(ids) } } - const diveIntoStatus = (id) => scrollTo(new Set([id])) - const diveToTopLevel = () => scrollTo(new Set([currentAncestors.value[0].id])) + const diveIntoStatus = (id) => setFocused(id) + const diveToTopLevel = () => setFocused(currentAncestors.value[0].id) watch(focusedId, async (neu, old) => { // Ignoring initial update (null -> id) since that is handled by scroll compensation diff --git a/src/components/conversation/conversation.vue b/src/components/conversation/conversation.vue index b6fd34ebb..893d84591 100644 --- a/src/components/conversation/conversation.vue +++ b/src/components/conversation/conversation.vue @@ -125,7 +125,7 @@ 0 }, + // TODO move muting logic into some store muteReasons() { return [ this.userIsMuted ? 'user' : null, diff --git a/src/components/status/status.vue b/src/components/status/status.vue index fa288145f..0306ff2cb 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -235,7 +235,7 @@ />