From 2b0a62287542597f9f53f45cd932efeb8ec0a12e Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Sat, 2 Nov 2024 11:30:56 -0400 Subject: [PATCH] separate following feed's menu component from the actual filter options --- .../frontend/src/pages/following-feed.vue | 30 +++----- .../frontend/src/pages/user/recent-notes.vue | 4 +- .../src/scripts/following-feed-utils.ts | 72 +++++++++---------- 3 files changed, 46 insertions(+), 60 deletions(-) diff --git a/packages/frontend/src/pages/following-feed.vue b/packages/frontend/src/pages/following-feed.vue index 9054769034..21e76b9094 100644 --- a/packages/frontend/src/pages/following-feed.vue +++ b/packages/frontend/src/pages/following-feed.vue @@ -25,7 +25,7 @@ SPDX-License-Identifier: AGPL-3.0-only diff --git a/packages/frontend/src/pages/user/recent-notes.vue b/packages/frontend/src/pages/user/recent-notes.vue index 6375979c00..d636068408 100644 --- a/packages/frontend/src/pages/user/recent-notes.vue +++ b/packages/frontend/src/pages/user/recent-notes.vue @@ -20,7 +20,7 @@ import { PageHeaderItem } from '@/types/page-header.js'; import MkPageHeader from '@/components/global/MkPageHeader.vue'; import SkUserRecentNotes from '@/components/SkUserRecentNotes.vue'; import { acct } from '@/filters/user.js'; -import { createModel, createOptions } from '@/scripts/following-feed-utils.js'; +import { createModel, createHeaderItem } from '@/scripts/following-feed-utils.js'; import MkStickyContainer from '@/components/global/MkStickyContainer.vue'; defineProps<{ @@ -44,7 +44,7 @@ const headerActions: PageHeaderItem[] = [ text: i18n.ts.reload, handler: () => userRecentNotes.value?.reload(), }, - createOptions(), + createHeaderItem(), ]; // Based on user/index.vue diff --git a/packages/frontend/src/scripts/following-feed-utils.ts b/packages/frontend/src/scripts/following-feed-utils.ts index 3b4020f84b..39f17949d6 100644 --- a/packages/frontend/src/scripts/following-feed-utils.ts +++ b/packages/frontend/src/scripts/following-feed-utils.ts @@ -9,6 +9,7 @@ import { deepMerge } from '@/scripts/merge.js'; import { PageHeaderItem } from '@/types/page-header.js'; import { i18n } from '@/i18n.js'; import { popupMenu } from '@/os.js'; +import { MenuItem } from '@/types/menu.js'; export const followingTab = 'following' as const; export const mutualsTab = 'mutuals' as const; @@ -80,43 +81,40 @@ export function createOptionsMenu(storage?: Ref): MenuItem[] { onlyFiles, } = createModel(storage); - return { - icon: 'ti ti-dots', - text: i18n.ts.options, - handler: ev => - popupMenu([ - { - type: 'switch', - text: i18n.ts.showNonPublicNotes, - ref: withNonPublic, - disabled: userList.value === 'followers', - }, - { - type: 'switch', - text: i18n.ts.showQuotes, - ref: withQuotes, - }, - { - type: 'switch', - text: i18n.ts.showBots, - ref: withBots, - }, - { - type: 'switch', - text: i18n.ts.showReplies, - ref: withReplies, - disabled: onlyFiles, - }, - { - type: 'divider', - }, - { - type: 'switch', - text: i18n.ts.fileAttachedOnly, - ref: onlyFiles, - disabled: withReplies, - }, - ], ev.currentTarget ?? ev.target), + return [ + { + type: 'switch', + text: i18n.ts.showNonPublicNotes, + ref: withNonPublic, + disabled: computed(() => userList.value === followersTab), + }, + { + type: 'switch', + text: i18n.ts.showQuotes, + ref: withQuotes, + }, + { + type: 'switch', + text: i18n.ts.showBots, + ref: withBots, + }, + { + type: 'switch', + text: i18n.ts.showReplies, + ref: withReplies, + disabled: onlyFiles, + }, + { + type: 'divider', + }, + { + type: 'switch', + text: i18n.ts.fileAttachedOnly, + ref: onlyFiles, + disabled: withReplies, + }, + ]; +} export function createModel(storage?: Ref): FollowingFeedModel { // eslint-disable-next-line no-param-reassign