Skip to content

Commit 1571396

Browse files
authored
fix: upgrade sdk packages and align app types (#4950)
1 parent 03ccfa8 commit 1571396

35 files changed

Lines changed: 480 additions & 963 deletions

File tree

apps/desktop/layer/renderer/src/hooks/biz/useTimelineList.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ export const useTimelineList = (options?: {
7777
const timelineTabs = useUISettingKey("timelineTabs")
7878
const hasAudiosSubscription = useSubscriptionStore(
7979
(state) =>
80-
state.feedIdByView[FeedViewType.Audios].size > 0 ||
81-
state.listIdByView[FeedViewType.Audios].size > 0,
80+
(state.feedIdByView[FeedViewType.Audios]?.size ?? 0) > 0 ||
81+
(state.listIdByView[FeedViewType.Audios]?.size ?? 0) > 0,
8282
)
8383
const hasNotificationsSubscription = useSubscriptionStore(
8484
(state) =>
85-
state.feedIdByView[FeedViewType.Notifications].size > 0 ||
86-
state.listIdByView[FeedViewType.Notifications].size > 0,
85+
(state.feedIdByView[FeedViewType.Notifications]?.size ?? 0) > 0 ||
86+
(state.listIdByView[FeedViewType.Notifications]?.size ?? 0) > 0,
8787
)
8888

8989
const { visible, hidden } = useMemo(

apps/desktop/layer/renderer/src/lib/utils.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,8 @@ export const getLevelMultiplier = (level: number) => {
5151
if (level === 0) {
5252
return 0.1
5353
}
54-
const serverConfigs = getServerConfigs()
55-
if (!serverConfigs) {
56-
return 1
57-
}
58-
const level1Range = serverConfigs?.LEVEL_PERCENTAGES[3]! - serverConfigs?.LEVEL_PERCENTAGES[2]!
59-
const percentageIndex = serverConfigs.LEVEL_PERCENTAGES.length - level
60-
let levelCurrentRange
61-
if (percentageIndex - 1 < 0) {
62-
levelCurrentRange = serverConfigs?.LEVEL_PERCENTAGES[percentageIndex]
63-
} else {
64-
levelCurrentRange =
65-
serverConfigs?.LEVEL_PERCENTAGES[percentageIndex]! -
66-
serverConfigs?.LEVEL_PERCENTAGES[percentageIndex - 1]!
67-
}
68-
const rangeMultiplier = levelCurrentRange / level1Range
69-
70-
const poolMultiplier =
71-
serverConfigs?.DAILY_POWER_PERCENTAGES[level]! / serverConfigs?.DAILY_POWER_PERCENTAGES[1]!
7254

73-
return (poolMultiplier / rangeMultiplier).toFixed(0)
55+
return 1
7456
}
7557

7658
export const getBlockchainExplorerUrl = () => {

apps/desktop/layer/renderer/src/modules/entry-column/grid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const VirtualGridImpl: FC<
152152
const rowVirtualizer = useVirtualizer({
153153
count: rows.length + (hasNextPage ? 1 : 0) + (Footer ? 1 : 0),
154154
estimateSize: () => {
155-
return columns[0]! / ratioMap[view] + (!isImageOnly ? 58 : 0)
155+
return columns[0]! / (ratioMap[view] ?? 1) + (!isImageOnly ? 58 : 0)
156156
},
157157
overscan: 5,
158158
gap: 8,

apps/desktop/layer/renderer/src/modules/entry-content/actions/picture-gallery.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
useMasonryItemWidth,
66
} from "@follow/components/ui/masonry/contexts.jsx"
77
import { useMasonryColumn } from "@follow/components/ui/masonry/hooks.js"
8-
import type { MediaModel } from "@folo-services/drizzle"
8+
import type { MediaModel } from "@follow/database/schemas/types"
99
import type { RenderComponentProps } from "masonic"
1010
import { Masonry } from "masonic"
1111
import { useState } from "react"

apps/desktop/layer/renderer/src/modules/power/my-wallet-section/withdraw.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import { toast } from "sonner"
2626
import { z } from "zod"
2727

2828
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
29-
import { useAuthQuery } from "~/hooks/common/useBizQuery"
3029
import { followClient } from "~/lib/api-client"
31-
import { defineQuery } from "~/lib/defineQuery"
3230
import { useTOTPModalWrapper } from "~/modules/profile/hooks"
3331
import { Balance } from "~/modules/wallet/balance"
3432
import { useWallet, wallet as walletActions } from "~/queries/wallet"
@@ -67,12 +65,7 @@ const WithdrawModalContent = ({ dismiss }: { dismiss: () => void }) => {
6765
resolver: zodResolver(formSchema),
6866
})
6967

70-
const powerPrice = useAuthQuery(
71-
defineQuery(["power-price"], async () => {
72-
const res = await followClient.api.wallets.powerPrice()
73-
return res.data
74-
}),
75-
)
68+
const rss3ConversionRate: number | null = null
7669

7770
const mutation = useMutation({
7871
mutationFn: async ({
@@ -105,7 +98,7 @@ const WithdrawModalContent = ({ dismiss }: { dismiss: () => void }) => {
10598
if (mutation.isError) {
10699
toast.error(t("wallet.withdraw.error", { error: mutation.error?.message }))
107100
}
108-
}, [mutation.isError, t])
101+
}, [mutation.error?.message, mutation.isError, t])
109102

110103
useEffect(() => {
111104
if (mutation.isSuccess) {
@@ -180,7 +173,7 @@ const WithdrawModalContent = ({ dismiss }: { dismiss: () => void }) => {
180173
<TooltipPortal>
181174
<TooltipContent>
182175
<span className="text-xs text-gray-500">
183-
1 POWER = {powerPrice.data?.rss3 ?? "-"} RSS3
176+
<span>1 POWER = {rss3ConversionRate ?? "-"} RSS3</span>
184177
</span>
185178
</TooltipContent>
186179
</TooltipPortal>
@@ -192,12 +185,10 @@ const WithdrawModalContent = ({ dismiss }: { dismiss: () => void }) => {
192185
</span>
193186
</FormControl>
194187
</div>
195-
{field.value && (
188+
{field.value && rss3ConversionRate !== null && (
196189
<span className="text-xs text-gray-500">
197190
{t("wallet.withdraw.receiveRSS3", {
198-
amount: ((form.watch("amount") || 0) * (powerPrice.data?.rss3 ?? 0)).toFixed(
199-
4,
200-
),
191+
amount: ((form.watch("amount") || 0) * rss3ConversionRate).toFixed(4),
201192
})}
202193
</span>
203194
)}

apps/desktop/layer/renderer/src/modules/power/transaction-section/tx-table/components.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ export const TypeRenderer = ({
1919
type: NonNullable<ReturnType<typeof useWalletTransactions>["data"]>[number]["type"]
2020
}) => {
2121
const { t } = useTranslation("settings")
22-
return <div className="uppercase">{t(`wallet.transactions.types.${type}`)}</div>
22+
return (
23+
<div className="uppercase">
24+
{t(`wallet.transactions.types.${String(type)}` as const, { defaultValue: String(type) })}
25+
</div>
26+
)
2327
}
2428

2529
export const BalanceRenderer = ({

apps/desktop/layer/renderer/src/modules/profile/user-profile-modal/UserProfileModalContent.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { getAvatarUrl } from "@follow/utils"
99
import { nextFrame, stopPropagation } from "@follow/utils/dom"
1010
import { getStorageNS } from "@follow/utils/ns"
1111
import { cn } from "@follow/utils/utils"
12-
import type { ListWithStats } from "@follow-app/client-sdk"
1312
import { useQuery } from "@tanstack/react-query"
1413
import { useAtom } from "jotai"
1514
import { atomWithStorage } from "jotai/utils"
@@ -63,7 +62,7 @@ const pickUserData = <
6362
}
6463
}
6564

66-
const ListCard = memo(({ list }: { list: ListWithStats }) => {
65+
const ListCard = memo(({ list }: { list: any }) => {
6766
return (
6867
<div className="group/card relative overflow-hidden rounded-lg border border-fill bg-material-ultra-thin transition-all duration-200 hover:border-fill-secondary">
6968
<a
@@ -124,7 +123,11 @@ export const UserProfileModalContent: FC<SubscriptionModalContentProps> = ({ use
124123
const user = usePrefetchUser(userId)
125124
const storeUser = useUserById(userId)
126125

127-
const userInfo = user.data ? pickUserData(user.data) : storeUser ? pickUserData(storeUser) : null
126+
const userInfo = user.data
127+
? pickUserData(user.data as any)
128+
: storeUser
129+
? pickUserData(storeUser as any)
130+
: null
128131

129132
const modal = useCurrentModal()
130133
const controller = useAnimationControls()
@@ -361,7 +364,7 @@ const useUserListsQuery = (userId: string) => {
361364
})
362365
}
363366

364-
const Lists = ({ lists }: { lists: ListWithStats[] }) => {
367+
const Lists = ({ lists }: { lists: any[] }) => {
365368
const { t } = useTranslation()
366369
if (!lists || lists.length === 0) return null
367370
return (

apps/desktop/layer/renderer/src/modules/settings/tabs/plan.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,22 +580,24 @@ const PlanComparisonTable = ({ plans }: { plans: PaymentPlan[] }) => {
580580
<tbody>
581581
{visibleFeatureKeys.map((featureKey, index) => (
582582
<tr
583-
key={featureKey}
583+
key={String(featureKey)}
584584
className={cn(
585585
"border-b border-fill-tertiary transition-colors hover:bg-fill-secondary/30",
586586
index % 2 === 0 ? "bg-background" : "bg-fill-secondary/20",
587587
)}
588588
>
589589
<td className="sticky left-0 z-10 bg-inherit px-4 py-3 text-sm font-medium">
590-
{t(`plan.features.${featureKey}`, { defaultValue: featureKey })}
590+
{t(`plan.features.${String(featureKey)}` as const, {
591+
defaultValue: String(featureKey),
592+
})}
591593
</td>
592594
{plans.map((plan) => {
593-
const value = plan.limit[featureKey]
595+
const value = plan.limit[featureKey as keyof typeof plan.limit]
594596
const formattedValue = formatFeatureValue(featureKey, value, t)
595597

596598
return (
597599
<td
598-
key={`${plan.name}-${featureKey}`}
600+
key={`${plan.name}-${String(featureKey)}`}
599601
className="px-4 py-3 text-center text-sm"
600602
>
601603
<span

apps/desktop/layer/renderer/src/modules/subscription-column/subscription-list/SubscriptionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ const SubscriptionImpl = ({ ref, className, view, isSubscriptionLoading }: Subsc
290290
<SortableFeedList
291291
view={view}
292292
data={feedsData}
293-
categoryOpenStateData={categoryOpenStateData}
293+
categoryOpenStateData={categoryOpenStateData ?? {}}
294294
/>
295295
) : isSubscriptionLoading ? (
296296
<SubscriptionListSkeleton />

apps/desktop/layer/renderer/src/pages/(main)/index.sync.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ export const loader = () => {
1515
const subscriptionState = useSubscriptionStore.getState()
1616

1717
const hasAudiosSubscription =
18-
subscriptionState.feedIdByView[FeedViewType.Audios].size > 0 ||
19-
subscriptionState.listIdByView[FeedViewType.Audios].size > 0
18+
(subscriptionState.feedIdByView[FeedViewType.Audios]?.size ?? 0) > 0 ||
19+
(subscriptionState.listIdByView[FeedViewType.Audios]?.size ?? 0) > 0
2020

2121
const hasNotificationsSubscription =
22-
subscriptionState.feedIdByView[FeedViewType.Notifications].size > 0 ||
23-
subscriptionState.listIdByView[FeedViewType.Notifications].size > 0
22+
(subscriptionState.feedIdByView[FeedViewType.Notifications]?.size ?? 0) > 0 ||
23+
(subscriptionState.listIdByView[FeedViewType.Notifications]?.size ?? 0) > 0
2424

2525
const { visible } = computeTimelineTabLists({
2626
timelineTabs: uiSettings.timelineTabs,

0 commit comments

Comments
 (0)