Skip to content

Commit

Permalink
adding the bridge back in but without routing now...
Browse files Browse the repository at this point in the history
  • Loading branch information
burtonator committed Dec 30, 2024
1 parent 0e6f32c commit 5871222
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
2 changes: 2 additions & 0 deletions packages/commonwealth/client/scripts/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { HelmetProvider } from 'react-helmet-async';
import { RouterProvider } from 'react-router-dom';
import { ToastContainer } from 'react-toastify';
import { queryClient } from 'state/api/config';
import { ReactNativeBridge } from 'views/components/ReactNativeBridge';
import { Splash } from './Splash';
import { openFeatureProvider } from './helpers/feature-flags';
import useAppStatus from './hooks/useAppStatus';
Expand Down Expand Up @@ -37,6 +38,7 @@ const App = () => {
) : (
<>
<Mava />
<ReactNativeBridge />
<RouterProvider router={router()} />
{isAddedToHomeScreen || isMarketingPage ? null : (
<AddToHomeScreenPrompt
Expand Down
2 changes: 0 additions & 2 deletions packages/commonwealth/client/scripts/navigation/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Route,
} from 'react-router-dom';
import { fetchCachedCustomDomain } from 'state/api/configuration';
import { ReactNativeBridge } from 'views/components/ReactNativeBridge';
import { withLayout } from 'views/Layout';
import { PageNotFound } from 'views/pages/404';
import CommonDomainRoutes from './CommonDomainRoutes';
Expand Down Expand Up @@ -39,7 +38,6 @@ const Router = () => {
: CommonDomainRoutes(flags)),
<>
<Route key="routes" path="*" element={withLayout(PageNotFound, {})} />,
<ReactNativeBridge />
</>,
]),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import useUserStore from 'client/scripts/state/ui/user';
import { useCallback, useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';

interface ReactNativeWebView {
// allows us to send messages to ReactNative.
Expand Down Expand Up @@ -65,25 +64,22 @@ function isNavigateBack(data: object): data is NavigateBack {
*/
export const ReactNativeBridge = () => {
const user = useUserStore();
const navigate = useNavigate();
// const navigate = useNavigate();

const [userInfo, setUserInfo] = useState<UserInfo | null>(null);

const handleMessage = useCallback(
(message: MessageEvent) => {
const obj = messageToObject(message.data);
if (obj && typeof message.data === 'object') {
if (isNavigateToLink(obj)) {
navigate(getPathAndQuery(obj.link));
}

if (isNavigateBack(obj)) {
navigate(-1);
}
}
},
[navigate],
);
const handleMessage = useCallback((message: MessageEvent) => {
const obj = messageToObject(message.data);

Check warning on line 72 in packages/commonwealth/client/scripts/views/components/ReactNativeBridge/ReactNativeBridge.tsx

View workflow job for this annotation

GitHub Actions / Code Quality Recommendations (22)

'obj' is assigned a value but never used

Check warning on line 72 in packages/commonwealth/client/scripts/views/components/ReactNativeBridge/ReactNativeBridge.tsx

View workflow job for this annotation

GitHub Actions / Code Quality checks (22)

'obj' is assigned a value but never used
// if (obj && typeof message.data === 'object') {
// if (isNavigateToLink(obj)) {
// navigate(getPathAndQuery(obj.link));
// }
//
// if (isNavigateBack(obj)) {
// navigate(-1);
// }
// }
}, []);

useEffect(() => {
window.addEventListener('message', handleMessage);
Expand Down

0 comments on commit 5871222

Please sign in to comment.