diff --git a/packages/pl-api/lib/params/lists.ts b/packages/pl-api/lib/params/lists.ts index 3eec175fb..2536302a6 100644 --- a/packages/pl-api/lib/params/lists.ts +++ b/packages/pl-api/lib/params/lists.ts @@ -10,12 +10,22 @@ interface CreateListParams { replies_policy?: 'followed' | 'list' | 'none'; /** Boolean. Whether members of this list need to get removed from the “Home” feed */ exclusive?: boolean; + /** + * Boolean. Whether to receive notifications for new posts in the list. + * Requires features{@link Features['listsNotifications']} + */ + notify?: boolean; + /** + * Boolean. Whether the list should appear in the navigation bar. + * Requires features{@link Features['listsFavourites']} + */ + favourite?: boolean; } /** * @category Request params */ -type UpdateListParams = CreateListParams; +type UpdateListParams = Partial; /** * @category Request params diff --git a/packages/pl-fe/src/locales/en.json b/packages/pl-fe/src/locales/en.json index 45151d105..a2fa625d4 100644 --- a/packages/pl-fe/src/locales/en.json +++ b/packages/pl-fe/src/locales/en.json @@ -1097,8 +1097,10 @@ "lists.account.remove": "List members", "lists.delete": "Delete list", "lists.edit": "Edit list", + "lists.edit.error": "Error updating list", "lists.edit.save": "Save list", "lists.edit.show_replies_to": "Include replies from list members to", + "lists.edit.success": "List updated successfully", "lists.edit.title": "List title", "lists.exclusive": "Hide members in Home", "lists.exclusive_hint": "If someone is on this list, hide them in your Home feed to avoid seeing their posts twice.", @@ -1108,7 +1110,7 @@ "lists.new.save": "Save list", "lists.new.title_placeholder": "New list title", "lists.notifications": "Subscribe", - "lists.notifications_hint": "Subscribe to receive notifications for new posts in the list.", + "lists.notifications_hint": "Receive notifications for new posts in the list.", "lists.replies_policy.followed": "Any followed user", "lists.replies_policy.list": "Members of the list", "lists.replies_policy.none": "No one", diff --git a/packages/pl-fe/src/modals/list-editor-modal/components/edit-list-form.tsx b/packages/pl-fe/src/modals/list-editor-modal/components/edit-list-form.tsx index 9d22a052d..93bda3ef9 100644 --- a/packages/pl-fe/src/modals/list-editor-modal/components/edit-list-form.tsx +++ b/packages/pl-fe/src/modals/list-editor-modal/components/edit-list-form.tsx @@ -11,12 +11,15 @@ import Toggle from 'pl-fe/components/ui/toggle'; import { SelectDropdown } from 'pl-fe/features/forms'; import { useFeatures } from 'pl-fe/hooks/use-features'; import { useList, useUpdateList } from 'pl-fe/queries/accounts/use-lists'; +import toast from 'pl-fe/toast'; const messages = defineMessages({ save: { id: 'lists.new.save', defaultMessage: 'Save list' }, repliesPolicyNone: { id: 'lists.replies_policy.none', defaultMessage: 'No one' }, repliesPolicyList: { id: 'lists.replies_policy.list', defaultMessage: 'Members of the list' }, repliesPolicyFollowed: { id: 'lists.replies_policy.followed', defaultMessage: 'Any followed user' }, + success: { id: 'lists.edit.success', defaultMessage: 'List updated successfully' }, + error: { id: 'lists.edit.error', defaultMessage: 'Error updating list' }, }); interface IListForm { @@ -34,6 +37,7 @@ const ListForm: React.FC = ({ const { data: list } = useList(listId); const { mutate: updateList, isPending: disabled } = useUpdateList(listId!); + console.log(list); const [title, setTitle] = useState(list!.title); const [repliesPolicy, setRepliesPolicy] = useState(list!.replies_policy); const [exclusive, setExclusive] = useState(list!.exclusive); @@ -45,7 +49,14 @@ const ListForm: React.FC = ({ }; const handleUpdate = () => { - updateList({ title, replies_policy: repliesPolicy, exclusive }); + updateList({ title, replies_policy: repliesPolicy, exclusive, notify }, { + onSuccess: () => { + toast.success(intl.formatMessage(messages.success)); + }, + onError: () => { + toast.error(intl.formatMessage(messages.error)); + }, + }); }; return ( @@ -95,7 +106,7 @@ const ListForm: React.FC = ({ {features.listsNotifications && ( } - hint={} + hint={} >