From 7e191d729678001eaebc8e6fbf698bdd9b743cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sun, 8 Jan 2023 21:08:45 +0100 Subject: [PATCH] feat: support showing who favorited and boosted a status (#881) --- components/modal/ModalContainer.vue | 12 ++++ components/status/StatusActionsMore.vue | 11 ++++ .../status/StatusFavouritedBoostedBy.vue | 57 +++++++++++++++++++ composables/dialog.ts | 8 +++ locales/en-US.json | 3 + 5 files changed, 91 insertions(+) create mode 100644 components/status/StatusFavouritedBoostedBy.vue diff --git a/components/modal/ModalContainer.vue b/components/modal/ModalContainer.vue index fecf3f13..25ba1d62 100644 --- a/components/modal/ModalContainer.vue +++ b/components/modal/ModalContainer.vue @@ -5,6 +5,7 @@ import { isCommandPanelOpen, isConfirmDialogOpen, isEditHistoryDialogOpen, + isFavouritedBoostedByDialogOpen, isMediaPreviewOpen, isPreviewHelpOpen, isPublishDialogOpen, @@ -43,6 +44,10 @@ const handleConfirmChoice = (choice: ConfirmDialogChoice) => { confirmDialogChoice.value = choice isConfirmDialogOpen.value = false } + +const handleFavouritedBoostedByClose = () => { + isFavouritedBoostedByDialogOpen.value = false +} diff --git a/components/status/StatusActionsMore.vue b/components/status/StatusActionsMore.vue index 697d2c51..8365ac5f 100644 --- a/components/status/StatusActionsMore.vue +++ b/components/status/StatusActionsMore.vue @@ -111,6 +111,10 @@ async function editStatus() { editingStatus: status, }, true) } + +const showFavoritedAndBoostedBy = () => { + openFavoridedBoostedByDialog(status.id) +} + + +import { favouritedBoostedByStatusId } from '~/composables/dialog' + +const type = ref<'favourited-by' | 'boosted-by'>('favourited-by') + +function load() { + return useMasto().v1.statuses[type.value === 'favourited-by' ? 'listFavouritedBy' : 'listRebloggedBy'](favouritedBoostedByStatusId.value!) +} + +const paginator = $computed(() => load()) + +function showFavouritedBy() { + type.value = 'favourited-by' +} + +function showRebloggedBy() { + type.value = 'boosted-by' +} + +const { t } = useI18n() +const tabs = [ + { + name: 'favourited-by', + display: t('status.favourited_by'), + onClick: showFavouritedBy, + }, + { + name: 'boosted-by', + display: t('status.boosted_by'), + onClick: showRebloggedBy, + }, +] + + + diff --git a/composables/dialog.ts b/composables/dialog.ts index 5aab8372..46f9e08a 100644 --- a/composables/dialog.ts +++ b/composables/dialog.ts @@ -22,9 +22,12 @@ export const isEditHistoryDialogOpen = ref(false) export const isPreviewHelpOpen = ref(isFirstVisit.value) export const isCommandPanelOpen = ref(false) export const isConfirmDialogOpen = ref(false) +export const isFavouritedBoostedByDialogOpen = ref(false) export const lastPublishDialogStatus = ref(null) +export const favouritedBoostedByStatusId = ref(null) + export function openSigninDialog() { isSigninDialogOpen.value = true } @@ -62,6 +65,11 @@ export async function openPublishDialog(draftKey = 'dialog', draft?: Draft, over await until(isPublishDialogOpen).toBe(false) } +export async function openFavoridedBoostedByDialog(statusId: string) { + isFavouritedBoostedByDialogOpen.value = true + favouritedBoostedByStatusId.value = statusId +} + if (isPreviewHelpOpen.value) { watch(isPreviewHelpOpen, () => { isFirstVisit.value = false diff --git a/locales/en-US.json b/locales/en-US.json index e7891d62..8b2e81a5 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -146,6 +146,7 @@ "open_in_original_site": "Open in original site", "pin_on_profile": "Pin on profile", "share_post": "Share this post", + "show_favourited_and_boosted_by": "Show who favourited and boosted", "show_reblogs": "Show boosts from {0}", "show_untranslated": "Show untranslated", "toggle_theme": { @@ -346,7 +347,9 @@ "uploading": "Uploading..." }, "status": { + "boosted_by": "Boosted By", "edited": "Edited {0}", + "favourited_by": "Favorited By", "filter_hidden_phrase": "Filtered by", "filter_removed_phrase": "Removed by filter", "filter_show_anyway": "Show anyway",