Fix oidc links opening two times on web

This commit is contained in:
Zoe Roux 2024-03-10 15:22:53 +01:00
parent c6dd7203bb
commit 25b7903c37
3 changed files with 3 additions and 8 deletions

View File

@ -95,12 +95,13 @@ export const PressableFeedback = forwardRef<View, PressableProps>(function Feedb
});
export const Link = ({
href,
href: link,
replace,
target,
children,
...props
}: { href?: string | UrlObject | null; target?: string; replace?: boolean } & PressableProps) => {
const href = link && typeof link === "object" ? parseNextPath(link) : link;
const linkProps = useLink({
href: href ?? "#",
replace,
@ -115,11 +116,7 @@ export const Link = ({
onPress={(e?: any) => {
props?.onPress?.(e);
if (e?.defaultPrevented) return;
if (
(Platform.OS !== "web" && typeof href === "string" && href?.includes("://")) ||
(typeof href === "object" && href?.pathname?.includes("://"))
)
Linking.openURL(typeof href === "object" ? parseNextPath(href) : href);
if (Platform.OS !== "web" && href?.includes("://")) Linking.openURL(href);
else linkProps.onPress(e);
}}
>

View File

@ -50,7 +50,6 @@ export const OidcLogin = ({ apiUrl }: { apiUrl?: string }) => {
<Button
as={Link}
href={{ pathname: x.link, query: { apiUrl } }}
target="_blank"
key={x.displayName}
licon={
x.logoUrl != null && (

View File

@ -71,7 +71,6 @@ export const ServerUrlPage: QueryPage = () => {
<Link
key={x.displayName}
href={{ pathname: x.link, query: { apiUrl } }}
target="_blank"
{...css({ justifyContent: "center" })}
>
{x.logoUrl != null ? (