diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index aba8c1dc5..c6effa8cf 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -1113,7 +1113,7 @@ class PlApiClient { * @see {@link https://docs.pleroma.social/backend/development/API/pleroma_api/#get-apiv1pleromabookmark_folders} */ getBookmarkFolders: async () => { - const response = await this.request('/api/v1/pleroma/bookmark_folders'); + const response = await this.request(this.features.version.software === PLEROMA ? '/api/v1/pleroma/bookmark_folders' : '/api/v1/bookmark_categories'); return v.parse(filteredArray(bookmarkFolderSchema), response.json); }, @@ -1122,10 +1122,14 @@ class PlApiClient { * Creates a bookmark folder * * Requires features{@link Features['bookmarkFolders']}. + * Specifying folder emoji requires features{@link Features['bookmarkFolderEmojis']}. * @see {@link https://docs.pleroma.social/backend/development/API/pleroma_api/#post-apiv1pleromabookmark_folders} */ createBookmarkFolder: async (params: CreateBookmarkFolderParams) => { - const response = await this.request('/api/v1/pleroma/bookmark_folders', { method: 'POST', body: params }); + const response = await this.request( + this.features.version.software === PLEROMA ? '/api/v1/pleroma/bookmark_folders' : '/api/v1/bookmark_categories', + { method: 'POST', body: { title: params.name, ...params } }, + ); return v.parse(bookmarkFolderSchema, response.json); }, @@ -1134,10 +1138,14 @@ class PlApiClient { * Updates a bookmark folder * * Requires features{@link Features['bookmarkFolders']}. + * Specifying folder emoji requires features{@link Features['bookmarkFolderEmojis']}. * @see {@link https://docs.pleroma.social/backend/development/API/pleroma_api/#patch-apiv1pleromabookmark_foldersid} */ updateBookmarkFolder: async (bookmarkFolderId: string, params: UpdateBookmarkFolderParams) => { - const response = await this.request(`/api/v1/pleroma/bookmark_folders/${bookmarkFolderId}`, { method: 'PATCH', body: params }); + const response = await this.request( + `${this.features.version.software === PLEROMA ? '/api/v1/pleroma/bookmark_folders' : '/api/v1/bookmark_categories'}/${bookmarkFolderId}`, + { method: 'PATCH', body: { title: params.name, ...params } }, + ); return v.parse(bookmarkFolderSchema, response.json); }, @@ -1149,7 +1157,10 @@ class PlApiClient { * @see {@link https://docs.pleroma.social/backend/development/API/pleroma_api/#delete-apiv1pleromabookmark_foldersid} */ deleteBookmarkFolder: async (bookmarkFolderId: string) => { - const response = await this.request(`/api/v1/pleroma/bookmark_folders/${bookmarkFolderId}`, { method: 'DELETE' }); + const response = await this.request( + `${this.features.version.software === PLEROMA ? '/api/v1/pleroma/bookmark_folders' : '/api/v1/bookmark_categories'}/${bookmarkFolderId}`, + { method: 'DELETE' }, + ); return v.parse(bookmarkFolderSchema, response.json); }, @@ -2159,7 +2170,7 @@ class PlApiClient { if (params.content_type === 'text/markdown' && this.#instance.api_versions['kmyblue_markdown.fedibird.pl-api'] >= 1) { fixedParams.markdown = true; } - if (params.visibility?.startsWith('circle:')) { + if (params.visibility?.startsWith('api/v1/bookmark_categories')) { fixedParams.circle_id = params.visibility.slice(7); fixedParams.visibility = 'circle'; } diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index 4f53cdf34..6a481d0ce 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -373,7 +373,12 @@ const getFeatures = (instance: Instance) => { * @see PATCH /api/v1/pleroma/bookmark_folders/:id * @see DELETE /api/v1/pleroma/bookmark_folders/:id */ - bookmarkFolders: instance.api_versions['bookmark_folders.pleroma.pl-api'] >= 1, + bookmarkFolders: any([ + instance.api_versions['bookmark_folders.pleroma.pl-api'] >= 1, + instance.api_versions['kmyblue_bookmark_category.fedibird.pl-api'] >= 1, + ]), + + bookmarkFolderEmojis: instance.api_versions['bookmark_folders.pleroma.pl-api'] >= 1, /** * Can bookmark statuses. diff --git a/packages/pl-fe/src/features/ui/components/modals/edit-bookmark-folder-modal.tsx b/packages/pl-fe/src/features/ui/components/modals/edit-bookmark-folder-modal.tsx index 68f727a8d..13f588f56 100644 --- a/packages/pl-fe/src/features/ui/components/modals/edit-bookmark-folder-modal.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/edit-bookmark-folder-modal.tsx @@ -12,6 +12,7 @@ import EmojiPickerDropdown from 'pl-fe/features/emoji/components/emoji-picker-dr import { messages as emojiMessages } from 'pl-fe/features/emoji/containers/emoji-picker-dropdown-container'; import { useTextField } from 'pl-fe/hooks/forms/use-text-field'; import { useClickOutside } from 'pl-fe/hooks/use-click-outside'; +import { useFeatures } from 'pl-fe/hooks/use-features'; import { useBookmarkFolder, useUpdateBookmarkFolder } from 'pl-fe/queries/statuses/use-bookmark-folders'; import toast from 'pl-fe/toast'; @@ -97,6 +98,7 @@ interface EditBookmarkFolderModalProps { const EditBookmarkFolderModal: React.FC = ({ folderId, onClose }) => { const intl = useIntl(); + const features = useFeatures(); const { data: bookmarkFolder } = useBookmarkFolder(folderId); const { mutate: updateBookmarkFolder, isPending } = useUpdateBookmarkFolder(folderId); @@ -142,11 +144,13 @@ const EditBookmarkFolderModal: React.FC} > - + {features.bookmarkFolderEmojis && ( + + )}