fix: only can add feed to owned lists, fixed #863
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -99,7 +99,7 @@ const ContextMenuCheckboxItem = React.forwardRef<
|
||||
<ContextMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-checkbox select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-theme-item-hover focus:text-theme-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"relative flex cursor-checkbox select-none items-center rounded-sm px-8 py-1.5 text-sm outline-none focus:bg-theme-item-hover focus:text-theme-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"focus-within:outline-transparent",
|
||||
className,
|
||||
)}
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
useRemoveFeedFromFeedList,
|
||||
} from "~/store/feed"
|
||||
import { useInboxById } from "~/store/inbox"
|
||||
import { useListById, useListByView } from "~/store/list"
|
||||
import { useListById, useOwnedList } from "~/store/list"
|
||||
import { subscriptionActions, useSubscriptionByFeedId } from "~/store/subscription"
|
||||
|
||||
import { useNavigateEntry } from "./useNavigateEntry"
|
||||
@@ -51,7 +51,7 @@ export const useFeedActions = ({
|
||||
const { mutateAsync: addFeedToListMutation } = useAddFeedToFeedList()
|
||||
const { mutateAsync: removeFeedFromListMutation } = useRemoveFeedFromFeedList()
|
||||
|
||||
const listByView = useListByView(view!)
|
||||
const listByView = useOwnedList(view!)
|
||||
|
||||
const items = useMemo(() => {
|
||||
if (!feed) return []
|
||||
|
||||
@@ -16,7 +16,7 @@ import type { FeedViewType } from "~/lib/enum"
|
||||
import { showNativeMenu } from "~/lib/native-menu"
|
||||
import { cn, sortByAlphabet } from "~/lib/utils"
|
||||
import { getPreferredTitle, useAddFeedToFeedList, useFeedStore } from "~/store/feed"
|
||||
import { useListByView } from "~/store/list"
|
||||
import { useOwnedList } from "~/store/list"
|
||||
import { subscriptionActions, useSubscriptionByFeedId } from "~/store/subscription"
|
||||
import { useFeedUnreadStore } from "~/store/unread"
|
||||
|
||||
@@ -131,7 +131,7 @@ function FeedCategoryImpl({ data: ids, view, categoryOpenStateData }: FeedCatego
|
||||
|
||||
const addMutation = useAddFeedToFeedList()
|
||||
|
||||
const listList = useListByView(view!)
|
||||
const listList = useOwnedList(view!)
|
||||
|
||||
return (
|
||||
<div tabIndex={-1} onClick={stopPropagation}>
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { useWhoami } from "~/atoms/user"
|
||||
import type { FeedViewType } from "~/lib/enum"
|
||||
import type { ListModel } from "~/models"
|
||||
|
||||
@@ -9,3 +12,12 @@ export const useListById = (listId: Nullable<string>): ListModel | null =>
|
||||
export const useListByView = (view: FeedViewType) => {
|
||||
return useListStore((state) => Object.values(state.lists).filter((list) => list.view === view))
|
||||
}
|
||||
|
||||
export const useOwnedList = (view: FeedViewType) => {
|
||||
const whoami = useWhoami()
|
||||
const viewLists = useListByView(view)
|
||||
return useMemo(
|
||||
() => viewLists.filter((list) => list.ownerUserId === whoami?.id),
|
||||
[viewLists, whoami],
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user