From c60fd003ea20a57036e6ac738fd7fc367d59a6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Sun, 2 Nov 2025 12:13:40 +0100 Subject: [PATCH] pl-fe: allow editing account notes on mobile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- .../features/account/components/header.tsx | 27 +++++++++++++++++++ .../components/panels/account-note-panel.tsx | 1 - packages/pl-fe/src/locales/en.json | 4 +++ .../pl-fe/src/modals/text-field-modal.tsx | 4 +-- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/packages/pl-fe/src/features/account/components/header.tsx b/packages/pl-fe/src/features/account/components/header.tsx index 67e4ad23e..a5fb7cb6a 100644 --- a/packages/pl-fe/src/features/account/components/header.tsx +++ b/packages/pl-fe/src/features/account/components/header.tsx @@ -36,6 +36,7 @@ import { useUnblockAccountMutation, useUnmuteAccountMutation, useUnpinAccountMutation, + useUpdateAccountNoteMutation, } from 'pl-fe/queries/accounts/use-relationship'; import { useChats } from 'pl-fe/queries/chats'; import { queryClient } from 'pl-fe/queries/client'; @@ -95,6 +96,10 @@ const messages = defineMessages({ loadActivities: { id: 'account.load_activities', defaultMessage: 'Fetch latest posts' }, loadActivitiesSuccess: { id: 'account.load_activities.success', defaultMessage: 'Scheduled fetching latest posts' }, loadActivitiesFail: { id: 'account.load_activities.fail', defaultMessage: 'Failed to fetch latest posts' }, + note: { id: 'account_note.modal_header', defaultMessage: 'Edit note for @{name}' }, + notePlaceholder: { id: 'account_note.placeholder', defaultMessage: 'Add a note' }, + noteSaved: { id: 'account_note.success', defaultMessage: 'Note saved' }, + noteSaveFailed: { id: 'account_note.fail', defaultMessage: 'Failed to save note' }, }); interface IMovedNote { @@ -147,6 +152,7 @@ const Header: React.FC = ({ account }) => { const { mutate: pinAccount } = usePinAccountMutation(account?.id!); const { mutate: unpinAccount } = useUnpinAccountMutation(account?.id!); const { mutate: removeFromFollowers } = useRemoveAccountFromFollowersMutation(account?.id!); + const { mutate: updateAccountNote } = useUpdateAccountNoteMutation(account?.id!); const { openModal } = useModalsActions(); const settings = useSettings(); @@ -249,6 +255,19 @@ const Header: React.FC = ({ account }) => { .catch(() => toast.error(intl.formatMessage(messages.loadActivitiesFail))); }; + const onEditNote = () => { + openModal('TEXT_FIELD', { + heading: , + placeholder: intl.formatMessage(messages.notePlaceholder), + confirm: , + onConfirm: (value) => updateAccountNote(value, { + onSuccess: () => toast.success(messages.noteSaved), + onError: () => toast.error(messages.noteSaveFailed), + }), + text: account.relationship?.note || '', + }); + }; + const onReport = () => { dispatch(initReport(ReportableEntities.ACCOUNT, account)); }; @@ -487,6 +506,14 @@ const Header: React.FC = ({ account }) => { }); } + if (account.relationship && features.notes) { + menu.push({ + text: intl.formatMessage(messages.note, { name: account.acct }), + action: onEditNote, + icon: require('@phosphor-icons/core/regular/note-pencil.svg'), + }); + } + menu.push(null); if (features.removeFromFollowers && account.relationship?.followed_by) { diff --git a/packages/pl-fe/src/features/ui/components/panels/account-note-panel.tsx b/packages/pl-fe/src/features/ui/components/panels/account-note-panel.tsx index 234137481..5e00508b7 100644 --- a/packages/pl-fe/src/features/ui/components/panels/account-note-panel.tsx +++ b/packages/pl-fe/src/features/ui/components/panels/account-note-panel.tsx @@ -13,7 +13,6 @@ import type { Account as AccountEntity } from 'pl-api'; const messages = defineMessages({ placeholder: { id: 'account_note.placeholder', defaultMessage: 'Click to add a note' }, - saved: { id: 'generic.saved', defaultMessage: 'Saved' }, }); interface IAccountNotePanel { diff --git a/packages/pl-fe/src/locales/en.json b/packages/pl-fe/src/locales/en.json index 17ea2cb54..2d3f67f42 100644 --- a/packages/pl-fe/src/locales/en.json +++ b/packages/pl-fe/src/locales/en.json @@ -97,8 +97,12 @@ "account_moderation_modal.roles.admin": "Admin", "account_moderation_modal.roles.moderator": "Moderator", "account_moderation_modal.roles.user": "User", + "account_note.fail": "Failed to save note", "account_note.header": "Note", + "account_note.modal_header": "Edit note for @{name}", "account_note.placeholder": "Click to add a note", + "account_note.save": "Save note", + "account_note.success": "Note saved", "admin.announcements.action": "Create announcement", "admin.announcements.all_day": "All day", "admin.announcements.delete": "Delete", diff --git a/packages/pl-fe/src/modals/text-field-modal.tsx b/packages/pl-fe/src/modals/text-field-modal.tsx index d9dcbd42b..bb380f72a 100644 --- a/packages/pl-fe/src/modals/text-field-modal.tsx +++ b/packages/pl-fe/src/modals/text-field-modal.tsx @@ -12,7 +12,7 @@ interface TextFieldModalProps { heading: React.ReactNode; placeholder?: string; confirm: React.ReactNode; - onConfirm: (value?: string) => void; + onConfirm: (value: string) => void; onCancel?: () => void; confirmationTheme?: ButtonThemes; text?: string; @@ -28,7 +28,7 @@ const TextFieldModal: React.FC = ({ confirmationTheme, text, }) => { - const [value, setValue] = useState(text); + const [value, setValue] = useState(text || ''); const handleClick = () => { onClose('TEXT_FIELD');