Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
chore: rename to openLink
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed May 2, 2024
1 parent b438cce commit cd57d1e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build

# generated by platform-specific files
frontend/src/utils/request.ts
frontend/src/utils/openBrowser.ts
frontend/src/utils/openLink.ts

# generated by rust go bindings for local development
glalby
4 changes: 0 additions & 4 deletions frontend/platform_specific/http/src/utils/openBrowser.ts

This file was deleted.

4 changes: 4 additions & 0 deletions frontend/platform_specific/http/src/utils/openLink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const openLink = (url: string) => {
// opens the link in a new tab
window.open(url, "_blank");
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BrowserOpenURL } from "wailsjs/runtime/runtime";

export const openBrowser = (url: string) => {
export const openLink = (url: string) => {
// opens the link in the browser
try {
BrowserOpenURL(url);
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from "react-router-dom";
import { openBrowser } from "src/utils/openBrowser";
import { openLink } from "src/utils/openLink";

type Props = {
to: string;
Expand All @@ -20,7 +20,7 @@ export default function ExternalLink({ to, className, children }: Props) {
{children}
</Link>
) : (
<div className={className} onClick={() => openBrowser(to)}>
<div className={className} onClick={() => openLink(to)}>
{children}
</div>
);
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/screens/alby/AlbyAuthRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import AuthCodeForm from "src/components/AuthCodeForm";

import Loading from "src/components/Loading";
import { useInfo } from "src/hooks/useInfo";
import { openBrowser } from "src/utils/openBrowser"; // build the project for this to appear
import { openLink } from "src/utils/openLink"; // build the project for this to appear

export default function AlbyAuthRedirect() {
const { data: info } = useInfo();
Expand All @@ -18,12 +18,7 @@ export default function AlbyAuthRedirect() {
window.location.href = info.albyAuthUrl;
} else {
setIsOpened((isOpened) => {
if (!isOpened) {
// open in new tab if http protocol
if (window.location.protocol.startsWith("http"))
window.open(info.albyAuthUrl, "_blank");
else openBrowser(info.albyAuthUrl);
}
if (!isOpened) openLink(info.albyAuthUrl);
return true;
});
}
Expand Down

0 comments on commit cd57d1e

Please sign in to comment.