Skip to content

Commit

Permalink
fix: add nonce id for temp feed
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Aug 8, 2024
1 parent 8a31463 commit 8f81d99
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"lowdb": "7.0.1",
"markdown-it": "14.1.0",
"markdown-it-container": "4.0.0",
"nanoid": "5.0.7",
"ofetch": "1.3.4",
"path-to-regexp": "7.1.0",
"posthog-js": "1.150.0",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/renderer/src/modules/discover/feed-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { useFeedByIdOrUrl } from "@renderer/store/feed"
import { useSubscriptionByFeedId } from "@renderer/store/subscription"
import { feedUnreadActions } from "@renderer/store/unread"
import { useMutation } from "@tanstack/react-query"
import { Fragment, useEffect, useRef } from "react"
import { useEffect, useRef } from "react"
import { useForm } from "react-hook-form"
import { toast } from "sonner"
import { z } from "zod"
Expand Down Expand Up @@ -89,19 +89,20 @@ export const FeedForm: Component<{
) :
feedQuery.error ?
(
<div className="center flex-col gap-3">
<i className="i-mgc-bug-cute-re size-7 text-red-500" />
<div className="center grow flex-col gap-3">
<i className="i-mgc-close-cute-re size-7 text-red-500" />
<p>Error in fetching feed.</p>
<p className="break-all px-8 text-center">
{getFetchErrorMessage(feedQuery.error)}
</p>
</div>
) :
(
<Fragment>
<div className="center h-full grow flex-col">
<i className="i-mgc-question-cute-re mb-6 size-12 text-zinc-500" />
<p>Feed not found.</p>
<p>{url}</p>
</Fragment>
</div>
)}
</div>
)
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/src/store/feed/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { apiClient } from "@renderer/lib/api-fetch"
import type { FeedModel } from "@renderer/models"
import { FeedService } from "@renderer/services"
import { produce } from "immer"
import { nanoid } from "nanoid"

import { createZustandStore, doMutationAndTransaction } from "../utils/helper"
import type { FeedQueryParams, FeedState } from "./types"
Expand All @@ -28,6 +29,10 @@ class FeedActions {
for (const feed of feeds) {
if (feed.id) {
state.feeds[feed.id] = feed
} else {
// Store temp feed in memory
const nonce = nanoid(8)
state.feeds[nonce] = { ...feed, id: nonce }
}
}
}),
Expand Down

0 comments on commit 8f81d99

Please sign in to comment.