Skip to content

Commit

Permalink
FIX redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Mar 19, 2024
1 parent 5aa536a commit 39e33ab
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions docs-src/src/pages/meeting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,28 @@
*/
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Layout from '@theme/Layout';
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import useIsBrowser from '@docusaurus/useIsBrowser';
import { getDatabase, hasIndexedDB } from '../components/database';

const FILE_EVENT_ID = 'meeting-link-clicked';
const REDIRECT_TIME = 1000;

export default function Meeting() {
const { siteConfig } = useDocusaurusContext();

const [goalUrl, setGoalUrl] = useState(null);

const isBrowser = useIsBrowser();
useEffect(() => {
if (!isBrowser || !hasIndexedDB()) {
return;
}

(async () => {
const myParam = new URLSearchParams(window.location.search).get('f');
setGoalUrl('https://rxdb.pipedrive.com/scheduler/' + myParam + '/schedulr');
setTimeout(() => window.location.href = goalUrl, REDIRECT_TIME);

const database = await getDatabase();
const flagDoc = await database.getLocal(FILE_EVENT_ID);
if (flagDoc) {
Expand All @@ -37,13 +43,6 @@ export default function Meeting() {
})();
});


let goalUrl = 'https://rxdb.pipedrive.com/scheduler/';
if (isBrowser) {
const myParam = new URLSearchParams(window.location.search).get('f');
goalUrl += myParam + '/schedulr';
}

return (
<Layout
title={`Chat - ${siteConfig.title}`}
Expand All @@ -60,10 +59,11 @@ export default function Meeting() {
<p>
<b>You will be redirected in a few seconds.</b>
</p>
<p>
<a href={goalUrl}>Click here to open the meeting scheduler directly.</a>
</p>
<meta httpEquiv="Refresh" content={'0; url=' + goalUrl} />
{!!goalUrl && <>
<p>
<a href={goalUrl}>Click here to open the meeting scheduler directly.</a>
</p>
</>}
</div>
</main>
</Layout >
Expand Down

0 comments on commit 39e33ab

Please sign in to comment.