Skip to content

Commit

Permalink
feat: improved url handling
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas committed Apr 10, 2024
1 parent 1d2f019 commit 32b3dcd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VITE_DISABLED_EDITORS=powerhouse/document-drive
VITE_RENOWN_URL=http://localhost:3000
# VITE_RENOWN_URL=http://localhost:3000
VITE_DEFAULT_DRIVE_URL=https://apps.powerhouse.io/makerdao/switchboard/d/monetalis
VITE_BASE_HREF=/
ASSET_URL=/
Expand Down
19 changes: 11 additions & 8 deletions src/hooks/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ export const useLogin = () => {

const login = useCallback(async () => {
const connectId = await did();
const url = `${RENOWN_URL}?connect=${encodeURIComponent(connectId)}&network=${RENOWN_NETWORK_ID}`;
const url = new URL(RENOWN_URL);
url.searchParams.set('connect', connectId);
url.searchParams.set('network', RENOWN_NETWORK_ID);

setStatus('checking');
if (window.electronAPI) {
const protocol = await window.electronAPI.protocol();
await window.electronAPI.openURL(`${url}&deeplink=${protocol}`);
url.searchParams.set('deeplink', protocol);
await window.electronAPI.openURL(url.toString());
} else {
window
.open(
`${url}&returnUrl=${encodeURIComponent(`${window.location.origin}${window.location.pathname}`)}`,
'_self',
)
?.focus();
const returnUrl = new URL(
window.location.pathname,
window.location.origin,
);
url.searchParams.set('returnUrl', returnUrl.toJSON());
window.open(url, '_self')?.focus();
}
}, [did]);

Expand Down
2 changes: 1 addition & 1 deletion src/services/renown/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const RENOWN_URL =
(import.meta.env.VITE_RENOWN_URL as string) || 'https://renown.vercel.app/';
(import.meta.env.VITE_RENOWN_URL as string) || 'https://renown.vercel.app';
export const RENOWN_NETWORK_ID =
(import.meta.env.VITE_RENOWN_NETWORK_ID as string) || '1';

Expand Down

0 comments on commit 32b3dcd

Please sign in to comment.