diff --git a/apps/renderer/src/modules/boost/boosting-contributors.tsx b/apps/renderer/src/modules/boost/boosting-contributors.tsx
index 3a53bb6a3..c40cf15a5 100644
--- a/apps/renderer/src/modules/boost/boosting-contributors.tsx
+++ b/apps/renderer/src/modules/boost/boosting-contributors.tsx
@@ -5,6 +5,8 @@ import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
import { useFeedBoostersQuery } from "~/modules/boost/query"
import { usePresentUserProfileModal } from "../profile/hooks"
+import { UserGallery } from "../user/UserGallery"
+import type { User } from "../user/utils"
export const BoostingContributors = ({ feedId }: { feedId: string }) => {
const { data: boosters, isLoading } = useFeedBoostersQuery(feedId)
@@ -21,27 +23,34 @@ export const BoostingContributors = ({ feedId }: { feedId: string }) => {
>
Boosting Contributors
- {boosters
- .map((user) => (
- - presentUserProfile(user.id)}
- >
-
-
- {user.name?.slice(0, 2)}
-
-
-
{user.name || user.handle}
- {user.handle &&
@{user.handle}
}
-
-
+ {boosters.length < 8 ? (
+ boosters.map((user) => (
+
))
- // TODO use grid layout when there are many boosters
- .slice(0, 10)}
+ ) : (
+
+ )}
)
}
+
+const UserListItem = ({ user, onClick }: { user: User; onClick: (userId: string) => void }) => {
+ return (
+ onClick(user.id)}
+ >
+
+
+ {user.name?.slice(0, 2)}
+
+
+
{user.name || user.handle}
+ {user.handle &&
@{user.handle}
}
+
+
+ )
+}
diff --git a/apps/renderer/src/modules/entry-content/components/SupportCreator.tsx b/apps/renderer/src/modules/entry-content/components/SupportCreator.tsx
index 7e8b8e1a2..7ef3ae708 100644
--- a/apps/renderer/src/modules/entry-content/components/SupportCreator.tsx
+++ b/apps/renderer/src/modules/entry-content/components/SupportCreator.tsx
@@ -1,5 +1,6 @@
import { Button } from "@follow/components/ui/button/index.js"
import { Divider } from "@follow/components/ui/divider/index.js"
+import { useMemo } from "react"
import { useTranslation } from "react-i18next"
import { useWhoami } from "~/atoms/user"
@@ -7,9 +8,11 @@ import { useBoostModal } from "~/modules/boost/hooks"
import { useFeedBoostersQuery } from "~/modules/boost/query"
import { FeedIcon } from "~/modules/feed/feed-icon"
import { UserAvatar } from "~/modules/user/UserAvatar"
+import { deduplicateUsers } from "~/modules/user/utils"
import { useEntry } from "~/store/entry"
import { useFeedById } from "~/store/feed"
+import { UserGallery } from "../../user/UserGallery"
import { useTipModal } from "../../wallet/hooks"
export const SupportCreator = ({ entryId }: { entryId: string }) => {
@@ -26,10 +29,17 @@ export const SupportCreator = ({ entryId }: { entryId: string }) => {
const openBoostModal = useBoostModal()
const isMyOwnedFeed = feed?.ownerUserId === useWhoami()?.id
- if (!feed || feed.type !== "feed") return null
+ const allSupporters = useMemo(
+ () =>
+ deduplicateUsers([
+ ...(feed && "tipUsers" in feed && feed.tipUsers ? feed.tipUsers : []),
+ ...(feedBoosters ?? []),
+ ]),
+ [feed, feedBoosters],
+ )
+ const supportAmount = allSupporters.length
- const supportAmount =
- (feed && feed.tipUsers ? feed.tipUsers.length : 0) + (feedBoosters ? feedBoosters.length : 0)
+ if (!feed || feed.type !== "feed") return null
return (
<>
@@ -69,32 +79,7 @@ export const SupportCreator = ({ entryId }: { entryId: string }) => {
{t("entry_content.support_amount", { amount: supportAmount })}
-
- {feed.tipUsers?.map((user) => (
-
-
-
- ))}
-
-
- {feedBoosters?.map((user) => (
-
-
-
- ))}
-
+
>
)}
diff --git a/apps/renderer/src/modules/user/UserGallery.tsx b/apps/renderer/src/modules/user/UserGallery.tsx
new file mode 100644
index 000000000..3ad150f41
--- /dev/null
+++ b/apps/renderer/src/modules/user/UserGallery.tsx
@@ -0,0 +1,29 @@
+import { UserAvatar } from "~/modules/user/UserAvatar"
+
+import type { User } from "./utils"
+
+interface UserGalleryProps {
+ users: User[]
+ dedupe?: boolean
+ limit?: number
+}
+
+export const UserGallery = ({ users, limit = 18 }: UserGalleryProps) => {
+ const displayedUsers = users.slice(0, limit)
+
+ return (
+
+ {displayedUsers.map((user) => (
+
+
+
+ ))}
+
+ )
+}
diff --git a/apps/renderer/src/modules/user/utils.ts b/apps/renderer/src/modules/user/utils.ts
new file mode 100644
index 000000000..89c74173d
--- /dev/null
+++ b/apps/renderer/src/modules/user/utils.ts
@@ -0,0 +1,16 @@
+export interface User {
+ name: string | null
+ id: string
+ emailVerified: string | null
+ image: string | null
+ handle: string | null
+ createdAt: string
+}
+
+export const deduplicateUsers = (users: User[]): User[] => {
+ const userMap = new Map()
+ users.forEach((user) => {
+ userMap.set(user.id, user)
+ })
+ return Array.from(userMap.values())
+}
diff --git a/apps/renderer/src/store/feed/store.ts b/apps/renderer/src/store/feed/store.ts
index 2fb240e93..c0749b328 100644
--- a/apps/renderer/src/store/feed/store.ts
+++ b/apps/renderer/src/store/feed/store.ts
@@ -54,12 +54,13 @@ class FeedActions {
}
// Not all API return these fields, so merging is needed here.
- const optionalFields = ["owner", "tipUsers"] as const
- optionalFields.forEach((field) => {
- if (state.feeds[feed.id!]?.[field] && !(field in feed)) {
- ;(feed as any)[field] = { ...state.feeds[feed.id!]?.[field] }
- }
- })
+ const targetFeed = state.feeds[feed.id]
+ if (targetFeed?.owner) {
+ feed.owner = { ...targetFeed.owner }
+ }
+ if (targetFeed && "tipUsers" in targetFeed && targetFeed.tipUsers) {
+ feed.tipUsers = [...targetFeed.tipUsers]
+ }
state.feeds[feed.id] = omit(feed, "feeds") as FeedOrListModel
} else {