From 37e6e4901f73e4e68ac4eb6205a8dc57cde0a5b4 Mon Sep 17 00:00:00 2001 From: TerryM Date: Sat, 6 Jun 2026 00:04:19 +0800 Subject: [PATCH] fix: route favorites cards through /resource so they survive language switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Favorites are stored regardless of language but the card click was navigating to /browse?post=&single=1 in the current UI language. When the user switched languages (e.g. zh→en) and tapped a zh-only favorite, the /browse stream couldn't find the post in its English view and showed "Couldn't find this post in the current view". Make Favorites navigate via /resource/ instead. PostRedirect already tries the current UI language first, then falls back to the post's source language and shows a toast. Renamed PopularRankRow's seldom-used `singlePostLink` to `linkToResource` to make the intent obvious; Favorites passes the new prop. --- src/components/PopularRankList.tsx | 15 ++++++++++++--- src/pages/Favorites/index.tsx | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/PopularRankList.tsx b/src/components/PopularRankList.tsx index c939352..73a89f0 100644 --- a/src/components/PopularRankList.tsx +++ b/src/components/PopularRankList.tsx @@ -90,7 +90,7 @@ export function PopularRankRow({ browseSort = "popular", showRank = true, showDownload = true, - singlePostLink = false, + linkToResource = false, onFavoriteChange, }: { post: Post; @@ -99,7 +99,13 @@ export function PopularRankRow({ browseSort?: string; showRank?: boolean; showDownload?: boolean; - singlePostLink?: boolean; + /** + * When true, the card and download button route to `/resource/:id` so the + * `PostRedirect` page can fall back to the post's source language if the + * current UI language has no translation. Otherwise navigate inside the + * `/browse` stream which assumes the post exists in the current language. + */ + linkToResource?: boolean; onFavoriteChange?: (postId: string, favorited: boolean) => void; }) { const { t, lang } = useI18n(); @@ -143,10 +149,13 @@ export function PopularRankRow({