From 06e906f95e4bf1502d45516cb78251265e6aa1b8 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Mon, 8 Apr 2024 02:19:35 +0900 Subject: [PATCH] feat: show pinned posts on individual account page --- components/status/StatusCard.vue | 14 ++++++++++++++ pages/[[server]]/@[account]/index/index.vue | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/components/status/StatusCard.vue b/components/status/StatusCard.vue index 76cd88d1..3e211c47 100644 --- a/components/status/StatusCard.vue +++ b/components/status/StatusCard.vue @@ -62,6 +62,7 @@ const timeago = useTimeAgo(() => status.value.createdAt, timeAgoOptions) const isSelfReply = computed(() => status.value.inReplyToAccountId === status.value.account.id) const collapseRebloggedBy = computed(() => rebloggedBy.value?.id === status.value.account.id) const isDM = computed(() => status.value.visibility === 'direct') +const isPinned = computed(() => status.value.pinned) const showUpperBorder = computed(() => props.newer && !directReply.value) const showReplyTo = computed(() => !replyToMain.value && !directReply.value) @@ -113,6 +114,19 @@ const forceShow = ref(false) + + +
+
+
+ Pinned post +
+
diff --git a/pages/[[server]]/@[account]/index/index.vue b/pages/[[server]]/@[account]/index/index.vue index 506f722d..0728dbc4 100644 --- a/pages/[[server]]/@[account]/index/index.vue +++ b/pages/[[server]]/@[account]/index/index.vue @@ -10,11 +10,21 @@ const { t } = useI18n() const account = await fetchAccountByHandle(handle.value) +// we need to ensure `pinned === true` on status +// because this prop is appeared only on current account's posts +function applyPinned(statuses: mastodon.v1.Status[]) { + return statuses.map((status) => { + status.pinned = true + return status + }) +} + function reorderAndFilter(items: mastodon.v1.Status[]) { return reorderedTimeline(items, 'account') } -const paginator = useMastoClient().v1.accounts.$select(account.id).statuses.list({ limit: 30, excludeReplies: true }) +const pinnedPaginator = useMastoClient().v1.accounts.$select(account.id).statuses.list({ pinned: true }) +const accountPaginator = useMastoClient().v1.accounts.$select(account.id).statuses.list({ limit: 30, excludeReplies: true }) if (account) { useHydratedHead({ @@ -26,6 +36,9 @@ if (account) {