terry-wallet-login #15

Merged
terry merged 95 commits from terry-wallet-login into terry-staging 2026-06-05 16:32:43 +00:00
2 changed files with 17 additions and 8 deletions
Showing only changes of commit fd1a3f4b3e - Show all commits

View File

@@ -150,7 +150,7 @@ export function PopularRankRow({
type="button"
onClick={() => {
if (linkToResource) {
navigate(lp(`/resource/${encodeURIComponent(post.id)}`));
navigate(lp(`/resource/${encodeURIComponent(post.id)}?single=1`));
return;
}
const params = new URLSearchParams();

View File

@@ -1,5 +1,5 @@
import { useEffect, useRef } from "react";
import { useNavigate, useParams } from "react-router-dom";
import { useNavigate, useParams, useSearchParams } from "react-router-dom";
import { getJSON } from "../../api";
import { langQuery, useI18n, type Lang } from "../../i18n";
import { useLocalizedPath } from "../../useLocalizedPath";
@@ -25,6 +25,8 @@ function postLangToUiLang(code: string | undefined): Lang | null {
export function PostRedirect() {
const { id } = useParams();
const [sp] = useSearchParams();
const singleMode = sp.get("single") === "1";
const { lang, t } = useI18n();
const navigate = useNavigate();
const lp = useLocalizedPath();
@@ -41,18 +43,25 @@ export function PostRedirect() {
if (POST_STREAM_USES_MOCK) {
const post = MOCK_POSTS.find((p) => p.id === id);
const suffix = singleMode ? "&single=1" : "";
navigate(
lp(post ? `/browse?post=${encodeURIComponent(post.id)}` : "/browse"),
{
replace: true,
},
lp(
post
? `/browse?post=${encodeURIComponent(post.id)}${suffix}`
: "/browse",
),
{ replace: true },
);
return;
}
const goToPostInLang = (post: Post, targetLang: Lang) => {
const suffix = singleMode ? "&single=1" : "";
navigate(
localizePath(`/browse?post=${encodeURIComponent(post.id)}`, targetLang),
localizePath(
`/browse?post=${encodeURIComponent(post.id)}${suffix}`,
targetLang,
),
{ replace: true },
);
};
@@ -73,7 +82,7 @@ export function PostRedirect() {
})
.catch(() => navigate(lp("/browse"), { replace: true }));
});
}, [id, lang, navigate, lp, showToast, t]);
}, [id, lang, navigate, lp, showToast, singleMode, t]);
return (
<div