customURL - show modal popup instead of redirecting to a new page
This commit is contained in:
parent
f07a96165d
commit
1dd160e19f
|
|
@ -1,17 +1,16 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import jkCustomUrlScheme from '../../helpers/jkCustomUrlScheme';
|
import jkCustomUrlScheme from '../../helpers/jkCustomUrlScheme';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Card, CardBody, Row, Col } from 'reactstrap';
|
import { Row, Col } from 'reactstrap';
|
||||||
import FalconCardHeader from '../common/FalconCardHeader';
|
|
||||||
|
|
||||||
const JKCustomUrlSchemaHandle = () => {
|
const JKCustomUrlSchemaHandle = ({ customQueryString, toggle }) => {
|
||||||
const [urlScheme, setUrlScheme] = useState(null);
|
const [urlScheme, setUrlScheme] = useState(null);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const queryStr = window.location.search;
|
//const queryStr = window.location.search;
|
||||||
if (!queryStr) return;
|
if (!customQueryString) return;
|
||||||
const urlParams = new URLSearchParams(queryStr);
|
const urlParams = new URLSearchParams(customQueryString);
|
||||||
const action = urlParams.get('act');
|
const action = urlParams.get('act');
|
||||||
const params = urlParams.get('p');
|
const params = urlParams.get('p');
|
||||||
const appUrl = jkCustomUrlScheme(action, params);
|
const appUrl = jkCustomUrlScheme(action, params);
|
||||||
|
|
@ -27,9 +26,6 @@ const JKCustomUrlSchemaHandle = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Card>
|
|
||||||
<FalconCardHeader title={t('new.page_title', { ns: 'sessions' })} titleClass="font-weight-bold" />
|
|
||||||
<CardBody className="pt-0">
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
<div className="mt-8 text-center mb-8">
|
<div className="mt-8 text-center mb-8">
|
||||||
|
|
@ -40,15 +36,14 @@ const JKCustomUrlSchemaHandle = () => {
|
||||||
If you don't see the dialog, click <strong>Lauhch JamKazam App</strong> below.
|
If you don't see the dialog, click <strong>Lauhch JamKazam App</strong> below.
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<a href={urlScheme} className='btn btn-primary'>Lauhch JamKazam App</a>
|
<a href={urlScheme} className='btn btn-primary' onClick={toggle}>Lauhch JamKazam App</a>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</CardBody>
|
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import useNativeAppCheck from '../../hooks/useNativeAppCheck';
|
||||||
import { useNativeApp } from '../../context/NativeAppContext';
|
import { useNativeApp } from '../../context/NativeAppContext';
|
||||||
import { useResponsive } from '@farfetch/react-context-responsive';
|
import { useResponsive } from '@farfetch/react-context-responsive';
|
||||||
import { sessionPrivacyMap } from '../../config';
|
import { sessionPrivacyMap } from '../../config';
|
||||||
|
import JKAppLaunch from './JKAppLaunch';
|
||||||
|
|
||||||
const JKNewMusicSession = () => {
|
const JKNewMusicSession = () => {
|
||||||
const { currentUser } = useAuth();
|
const { currentUser } = useAuth();
|
||||||
|
|
@ -23,8 +24,9 @@ const JKNewMusicSession = () => {
|
||||||
const [invitees, setInvitees] = useState([]);
|
const [invitees, setInvitees] = useState([]);
|
||||||
const [privacy, setPrivacy] = useState('1');
|
const [privacy, setPrivacy] = useState('1');
|
||||||
const [submitted, setSubmitted] = useState(false);
|
const [submitted, setSubmitted] = useState(false);
|
||||||
const [showAppUnavailable, setShowAppUnavailable] = useState(false);
|
const [showAppLauncher, setShowAppLauncher] = useState(false);
|
||||||
const history = useHistory();
|
const [customQueryString, setCustomQueryString] = useState(null);
|
||||||
|
//const history = useHistory();
|
||||||
const formRef = useRef();
|
const formRef = useRef();
|
||||||
const isNativeAppAvailable = useNativeAppCheck();
|
const isNativeAppAvailable = useNativeAppCheck();
|
||||||
const { nativeAppUnavailable, setNativeAppUnavailable } = useNativeApp();
|
const { nativeAppUnavailable, setNativeAppUnavailable } = useNativeApp();
|
||||||
|
|
@ -88,13 +90,21 @@ const JKNewMusicSession = () => {
|
||||||
//check if jamkazam app is installed
|
//check if jamkazam app is installed
|
||||||
await isNativeAppAvailable();
|
await isNativeAppAvailable();
|
||||||
const q = `privacy~${payload.privacy}|description~${payload.description}|inviteeIds~${payload.inviteeIds}`;
|
const q = `privacy~${payload.privacy}|description~${payload.description}|inviteeIds~${payload.inviteeIds}`;
|
||||||
history.push(`/applaunch?act=createSession&p=${q}`);
|
setCustomQueryString(`act=createSession&p=${q}`);
|
||||||
|
//history.push(`/applaunch?act=createSession&p=${q}`);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toggleAppUnavilableModel();
|
toggleAppUnavilableModel();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (customQueryString) {
|
||||||
|
setShowAppLauncher(true);
|
||||||
|
}
|
||||||
|
}, [customQueryString]);
|
||||||
|
|
||||||
const handleOnSelect = submittedItems => {
|
const handleOnSelect = submittedItems => {
|
||||||
updateSessionInvitations(submittedItems);
|
updateSessionInvitations(submittedItems);
|
||||||
};
|
};
|
||||||
|
|
@ -122,6 +132,10 @@ const JKNewMusicSession = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleAppLauncher = () => {
|
||||||
|
setShowAppLauncher(prev => !prev);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Card>
|
<Card>
|
||||||
|
|
@ -215,6 +229,13 @@ const JKNewMusicSession = () => {
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</JKModalDialog>
|
</JKModalDialog>
|
||||||
|
<JKModalDialog
|
||||||
|
show={showAppLauncher}
|
||||||
|
onToggle={toggleAppLauncher}
|
||||||
|
title={t('new.page_title', { ns: 'sessions' })}
|
||||||
|
>
|
||||||
|
<JKAppLaunch customQueryString={customQueryString} toggle={toggleAppLauncher} />
|
||||||
|
</JKModalDialog>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useAuth } from '../../context/UserAuth';
|
import { useAuth } from '../../context/UserAuth';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { fetchUserLatencies } from '../../store/features/latencySlice';
|
import { fetchUserLatencies } from '../../store/features/latencySlice';
|
||||||
|
|
@ -15,6 +15,8 @@ import EnterIcon from '../../icons/enter.svg';
|
||||||
import JKInstrumentIcon from '../profile/JKInstrumentIcon';
|
import JKInstrumentIcon from '../profile/JKInstrumentIcon';
|
||||||
import {useHistory} from 'react-router-dom';
|
import {useHistory} from 'react-router-dom';
|
||||||
import useSessionHelper from './JKUseSessionHelper';
|
import useSessionHelper from './JKUseSessionHelper';
|
||||||
|
import JKModalDialog from '../common/JKModalDialog';
|
||||||
|
import JKAppLaunch from '../page/JKAppLaunch';
|
||||||
|
|
||||||
function JKSession({ session }) {
|
function JKSession({ session }) {
|
||||||
const { currentUser } = useAuth();
|
const { currentUser } = useAuth();
|
||||||
|
|
@ -24,6 +26,7 @@ function JKSession({ session }) {
|
||||||
const { setNativeAppUnavailable } = useNativeApp();
|
const { setNativeAppUnavailable } = useNativeApp();
|
||||||
const { sessionDescription } = useSessionHelper(session);
|
const { sessionDescription } = useSessionHelper(session);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const otherUserIds = session.participants.map(p => p.user.id);
|
const otherUserIds = session.participants.map(p => p.user.id);
|
||||||
const options = { currentUserId: currentUser.id, otherUserIds };
|
const options = { currentUserId: currentUser.id, otherUserIds };
|
||||||
|
|
@ -158,7 +161,12 @@ function JoinSessionButton({ session }) {
|
||||||
const isNativeAppAvailable = useNativeAppCheck();
|
const isNativeAppAvailable = useNativeAppCheck();
|
||||||
const { setNativeAppUnavailable } = useNativeApp();
|
const { setNativeAppUnavailable } = useNativeApp();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const history = useHistory();
|
//const history = useHistory();
|
||||||
|
|
||||||
|
const [showAppLauncher, setShowAppLauncher] = useState(false);
|
||||||
|
const customQueryString = `act=joinSession&p=session~${session.id}`;
|
||||||
|
|
||||||
|
const toggleAppLauncher = () => setShowAppLauncher(!showAppLauncher);
|
||||||
|
|
||||||
async function joinSession(e) {
|
async function joinSession(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
@ -167,8 +175,9 @@ function JoinSessionButton({ session }) {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
await isNativeAppAvailable();
|
await isNativeAppAvailable();
|
||||||
const q = `sessionId~${session.id}`;
|
//const q = `sessionId~${session.id}`;
|
||||||
history.push(`/applaunch?act=joinSession&p=${q}`);
|
//history.push(`/applaunch?act=joinSession&p=${q}`);
|
||||||
|
setShowAppLauncher(true);
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setNativeAppUnavailable(true);
|
setNativeAppUnavailable(true);
|
||||||
|
|
@ -177,6 +186,7 @@ function JoinSessionButton({ session }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
data-testid="joinBtn"
|
data-testid="joinBtn"
|
||||||
|
|
@ -193,6 +203,14 @@ function JoinSessionButton({ session }) {
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<JKModalDialog
|
||||||
|
show={showAppLauncher}
|
||||||
|
onToggle={toggleAppLauncher}
|
||||||
|
title={t('new.page_title', { ns: 'sessions' })}
|
||||||
|
>
|
||||||
|
<JKAppLaunch customQueryString={customQueryString} toggle={toggleAppLauncher} />
|
||||||
|
</JKModalDialog>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue