Skip to content

Commit

Permalink
fix: empty entry list will throw not found feed error, fixed #224
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Aug 15, 2024
1 parent eb2a845 commit c41756d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const FeedFoundCanBeFollowErrorFallback: FC<AppErrorFallbackProps> = ({
const { present } = useModalStack()
const navigate = useNavigate()
useResetErrorWhenRouteChange(resetError)

return (
<div className="flex w-full flex-col items-center justify-center rounded-md bg-theme-modal-background-opaque p-2">
<div className="center m-auto flex max-w-prose flex-col gap-4 text-center">
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/modules/discover/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export function DiscoverForm({ type }: { type: string }) {
</div>
<div className="space-y-6 text-sm">
{mutation.data?.map((item) => (
<Card key={item.feed.url || item.docs} className="select-text">
<Card data-feed-id={item.feed.id} key={item.feed.url || item.docs} className="select-text">
<CardHeader>
<FollowSummary
className="max-w-[462px]"
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/src/modules/entry-column/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { cn, isBizId } from "@renderer/lib/utils"
import { useFeed } from "@renderer/queries/feed"
import { entryActions, useEntry } from "@renderer/store/entry"
import { useFeedByIdSelector } from "@renderer/store/feed"
import { useSubscriptionByFeedId } from "@renderer/store/subscription"
import { useCallback, useEffect, useRef } from "react"
import type {
ScrollSeekConfiguration,
Expand Down Expand Up @@ -234,6 +235,12 @@ const AddFeedHelper = () => {
const feedId = useRouteParamsSelector((s) => s.feedId)
const feedQuery = useFeed({ id: feedId })

const hasSubscription = useSubscriptionByFeedId(feedId || "")

if (hasSubscription) {
return null
}

if (!feedId) {
return
}
Expand Down
19 changes: 12 additions & 7 deletions src/renderer/src/store/subscription/store.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { whoami } from "@renderer/atoms/user"
import { runTransactionInScope } from "@renderer/database"
import { apiClient } from "@renderer/lib/api-fetch"
import { FeedViewType } from "@renderer/lib/enum"
Expand Down Expand Up @@ -235,13 +236,17 @@ class SubscriptionActions {
// Clear feed's unread count
feedUnreadActions.updateByFeedId(feedId, 0)

return apiClient.subscriptions
.$delete({
json: {
feedId,
},
})
.then(() => feed)
return doMutationAndTransaction(
() =>
apiClient.subscriptions
.$delete({
json: {
feedId,
},
})
.then(() => feed),
() => SubscriptionService.removeSubscription(whoami()!.id, feedId),
)
}

async changeCategoryView(
Expand Down

0 comments on commit c41756d

Please sign in to comment.