pl-api: kmyblue stuff
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -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<CreateListParams>;
|
||||
|
||||
/**
|
||||
* @category Request params
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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<IListForm> = ({
|
||||
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<IListForm> = ({
|
||||
};
|
||||
|
||||
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<IListForm> = ({
|
||||
{features.listsNotifications && (
|
||||
<ListItem
|
||||
label={<FormattedMessage id='lists.notifications' defaultMessage='Subscribe' />}
|
||||
hint={<FormattedMessage id='lists.notifications_hint' defaultMessage='Subscribe to receive notifications for new posts in the list.' />}
|
||||
hint={<FormattedMessage id='lists.notifications_hint' defaultMessage='Receive notifications for new posts in the list.' />}
|
||||
>
|
||||
<Toggle
|
||||
checked={notify}
|
||||
|
||||
Reference in New Issue
Block a user