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

View File

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

View File

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