feat: list api in subscription modal

This commit is contained in:
DIYgod 2024-09-23 18:57:29 +08:00
parent 0454747762
commit 46e246aa17
No known key found for this signature in database
4 changed files with 27 additions and 6 deletions

View File

@ -12,14 +12,29 @@ export const usePresentFeedFormModal = () => {
const me = useWhoami()
const t = useI18n()
return useCallback(
(feedId: string) => {
(
params:
| {
feedId: string
}
| {
listId: string
},
) => {
if (me) {
present({
title: t("sidebar.feed_actions.edit_feed"),
content: ({ dismiss }) => <FeedForm asWidget id={feedId} onSuccess={dismiss} />,
content: ({ dismiss }) => (
<FeedForm
asWidget
id={"feedId" in params ? params.feedId : params.listId}
isList={!!("listId" in params)}
onSuccess={dismiss}
/>
),
})
} else {
window.location.href = `${DEEPLINK_SCHEME}add?id=${feedId}`
window.location.href = `${DEEPLINK_SCHEME}add?id=${"feedId" in params ? params.feedId : params.listId}`
}
},
[me, present, t],

View File

@ -117,7 +117,9 @@ export function Component() {
)}
<Button
onClick={() => {
presentFeedFormModal(id!)
presentFeedFormModal({
feedId: id!,
})
}}
>
<FollowIcon className="mr-1 size-3" />

View File

@ -54,7 +54,9 @@ export function Component() {
<span className="center mb-8 flex gap-4">
<Button
onClick={() => {
presentFeedFormModal(id!)
presentFeedFormModal({
listId: id!,
})
}}
>
<FollowIcon className="mr-1 size-3" />

View File

@ -106,7 +106,9 @@ export function Component() {
onClick={(e) => {
e.stopPropagation()
presentFeedFormModal(subscription.feedId)
presentFeedFormModal({
feedId: subscription.feedId,
})
}}
>
{isMe ? (