Skip to content

Commit

Permalink
new router invite links
Browse files Browse the repository at this point in the history
  • Loading branch information
shocknet-justin committed Sep 15, 2024
1 parent ed871fc commit e63a767
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 23 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IonReactRouter } from "@ionic/react-router";
import { StatusBar } from "@capacitor/status-bar";
import AppUrlListener from "./Hooks/appUrlListener";
import ErrorBoundary from "./Hooks/ErrorBoundary";
import { useDispatch } from 'react-redux';

import './App.scss';
import store from './State/store';
Expand All @@ -23,7 +24,6 @@ import { Contacts } from './Pages/Contacts';
import { Invitations } from './Pages/Invitations';
import { Auth } from './Pages/Auth';
import { Background } from './Components/Background';
import { isBrowser } from 'react-device-detect'
import { Notify } from './Pages/Notify';
import { Metrics } from './Pages/Metrics';
import { Manage } from "./Pages/Manage";
Expand Down Expand Up @@ -54,9 +54,29 @@ import LoadingOverlay from "./Components/LoadingOverlay";
setupIonicReact();

const App: React.FC = () => {
const dispatch = useDispatch();

useEffect(() => {
if (!isBrowser) setStatusBarColor(); // check wonder it is opened in browser
}, []);
const handleUrlParams = () => {
const url = new URL(window.location.href);
const addSource = url.searchParams.get('addSource');
const inviteToken = url.searchParams.get('inviteToken');

if (addSource) {
// Dispatch an action to show the confirmation dialog
dispatch({ type: 'SHOW_ADD_SOURCE_CONFIRMATION', payload: { addSource, inviteToken } });
// Clear the URL parameters
window.history.replaceState({}, document.title, url.pathname);
}
};

handleUrlParams();
window.addEventListener('popstate', handleUrlParams);

return () => {
window.removeEventListener('popstate', handleUrlParams);
};
}, [dispatch]);

const setStatusBarColor = async () => {

Check failure on line 81 in src/App.tsx

View workflow job for this annotation

GitHub Actions / build

'setStatusBarColor' is assigned a value but never used. Allowed unused vars must match /^_/u
await StatusBar.setBackgroundColor({ color: "#16191c" });
Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Invitations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const Invitations = () => {


const reusableLink = selectedSource ? {
link: `${WALLET_URL}/#/sources?addSource=${selectedSource.pasteField}`,
link: `${WALLET_URL}/sources?addSource=${selectedSource.pasteField}`,
subNode: selectedSource.label,
} : null;

Expand Down Expand Up @@ -117,7 +117,7 @@ export const Invitations = () => {
<div className="link-group">
{ invitations.invitations &&
invitations.invitations.map(inv => {
const link = `${WALLET_URL}/#/sources?addSource=${selectedSource?.pasteField}&inviteToken=${inv.inviteToken}`
const link = `${WALLET_URL}/sources?addSource=${selectedSource?.pasteField}&inviteToken=${inv.inviteToken}`
return (
<div key={inv.inviteToken} className="content">
<div className="text">
Expand Down

0 comments on commit e63a767

Please sign in to comment.