Skip to content

Commit

Permalink
feat: add quick access for add feed to list
Browse files Browse the repository at this point in the history
  • Loading branch information
ischanx committed Oct 6, 2024
1 parent 7938364 commit 1a85142
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
51 changes: 30 additions & 21 deletions apps/renderer/src/hooks/biz/useFeedActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useFeedClaimModal } from "~/modules/claim"
import { FeedForm } from "~/modules/discover/feed-form"
import { InboxForm } from "~/modules/discover/inbox-form"
import { ListForm } from "~/modules/discover/list-form"
import { useSettingModal } from "~/modules/settings/modal/hooks"
import {
getFeedById,
useAddFeedToFeedList,
Expand All @@ -37,7 +38,7 @@ export const useFeedActions = ({
const { t } = useTranslation()
const feed = useFeedById(feedId)
const subscription = useSubscriptionByFeedId(feedId)

const settingModalPresent = useSettingModal()
const { present } = useModalStack()
const deleteSubscription = useDeleteSubscription({})
const claimFeed = useFeedClaimModal({
Expand Down Expand Up @@ -88,33 +89,40 @@ export const useFeedActions = ({
{
type: "separator" as const,
disabled: isEntryList,
enabled: !!listByView?.length,
},
{
type: "text" as const,
label: t("sidebar.feed_column.context_menu.add_feeds_to_list"),
enabled: !!listByView?.length,
submenu: listByView?.map((list) => {
const isIncluded = list.feedIds.includes(feedId)
return {
label: list.title || "",
submenu: [
...listByView.map((list) => {
const isIncluded = list.feedIds.includes(feedId)
return {
label: list.title || "",
type: "text" as const,
checked: isIncluded,
click() {
if (!isIncluded) {
addFeedToListMutation({
feedId,
listId: list.id,
})
} else {
removeFeedFromListMutation({
feedId,
listId: list.id,
})
}
},
}
}),
{
label: t("sidebar.feed_actions.create_list"),
type: "text" as const,
checked: isIncluded,
click() {
if (!isIncluded) {
addFeedToListMutation({
feedId,
listId: list.id,
})
} else {
removeFeedFromListMutation({
feedId,
listId: list.id,
})
}
settingModalPresent("list")
},
}
}),
},
],
},
{
type: "separator" as const,
Expand Down Expand Up @@ -212,6 +220,7 @@ export const useFeedActions = ({
claimFeed,
addFeedToListMutation,
removeFeedFromListMutation,
settingModalPresent,
present,
deleteSubscription,
subscription,
Expand Down
1 change: 1 addition & 0 deletions locales/app/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"sidebar.feed_actions.copy_feed_url": "Copy feed URL",
"sidebar.feed_actions.copy_list_id": "Copy list ID",
"sidebar.feed_actions.copy_list_url": "Copy list URL",
"sidebar.feed_actions.create_list": "Create New list",
"sidebar.feed_actions.edit": "Edit",
"sidebar.feed_actions.edit_feed": "Edit feed",
"sidebar.feed_actions.edit_inbox": "Edit inbox",
Expand Down
1 change: 1 addition & 0 deletions locales/app/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"sidebar.feed_actions.copy_feed_url": "复制链接",
"sidebar.feed_actions.copy_list_id": "复制列表 ID",
"sidebar.feed_actions.copy_list_url": "复制列表链接",
"sidebar.feed_actions.create_list": "创建列表",
"sidebar.feed_actions.edit": "编辑",
"sidebar.feed_actions.edit_feed": "编辑订阅",
"sidebar.feed_actions.edit_inbox": "编辑收件箱",
Expand Down
1 change: 1 addition & 0 deletions locales/app/zh-HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"sidebar.feed_actions.copy_feed_url": "複製訂閱源 URL",
"sidebar.feed_actions.copy_list_id": "複製清單 ID",
"sidebar.feed_actions.copy_list_url": "複製清單 URL",
"sidebar.feed_actions.create_list": "建立清單",
"sidebar.feed_actions.edit": "編輯",
"sidebar.feed_actions.edit_feed": "編輯訂閱源",
"sidebar.feed_actions.edit_inbox": "編輯收件箱",
Expand Down
1 change: 1 addition & 0 deletions locales/app/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"sidebar.feed_actions.copy_feed_url": "複製摘要 URL",
"sidebar.feed_actions.copy_list_id": "複製列表 ID",
"sidebar.feed_actions.copy_list_url": "複製列表連結",
"sidebar.feed_actions.create_list": "建立列表",
"sidebar.feed_actions.edit": "編輯",
"sidebar.feed_actions.edit_feed": "編輯摘要",
"sidebar.feed_actions.edit_inbox": "編輯收件匣",
Expand Down
2 changes: 1 addition & 1 deletion locales/settings/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"invitation.tableHeaders.creationTime": "创建时间",
"invitation.tableHeaders.usedBy": "使用者",
"invitation.title": "邀请码",
"lists.create": "创建新列表",
"lists.create": "创建列表",
"lists.created.error": "创建列表失败",
"lists.created.success": "创建列表成功",
"lists.description": "描述",
Expand Down

0 comments on commit 1a85142

Please sign in to comment.