Skip to content

Commit

Permalink
Merge pull request #1316 from near/fixes
Browse files Browse the repository at this point in the history
VM Fixes
  • Loading branch information
gagdiez authored Oct 9, 2024
2 parents 5134caf + 8a245f9 commit 62da1f1
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 93 deletions.
18 changes: 10 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions src/components/near-org/ComponentWrapperPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { useEffect } from 'react';

import { VmComponent } from '@/components/vm/VmComponent';
import { useGatewayEvents } from '@/hooks/useGatewayEvents';
import { useCurrentComponentStore } from '@/stores/current-component';

import { MetaTags } from '../MetaTags';

Expand All @@ -16,26 +13,8 @@ type Props = {
};

export function ComponentWrapperPage(props: Props) {
const setCurrentComponentSrc = useCurrentComponentStore((store) => store.setSrc);
const { emitGatewayEvent } = useGatewayEvents();

useEffect(() => {
if (
props.componentProps &&
'targetComponent' in props.componentProps &&
typeof props.componentProps.targetComponent === 'string'
) {
/*
If we're rendering a wrapper component, we want to display the component being wrapped
(props.componentProps.targetComponent). Without this check, we'd be rendering "GatewayWrapper"
or "TosCheck" as the current component instead of something like "ActivityPage".
*/
setCurrentComponentSrc(props.componentProps.targetComponent);
} else {
setCurrentComponentSrc(props.src);
}
}, [setCurrentComponentSrc, props]);

return (
<>
{props.meta && <MetaTags {...props.meta} />}
Expand Down
4 changes: 0 additions & 4 deletions src/data/links.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/hooks/useClearCurrentComponent.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/pages/[...arbitrary].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const finiteRoutes: Record<string, string> = {
import IframeResizer from '@iframe-resizer/react';
import type { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next';

import { useClearCurrentComponent } from '@/hooks/useClearCurrentComponent';
import { useDefaultLayout } from '@/hooks/useLayout';
import type { NextPageWithLayout } from '@/utils/types';

Expand Down Expand Up @@ -102,7 +101,6 @@ export const getStaticProps: GetStaticProps<StaticProps> = async (context) => {
};

const IframePage: NextPageWithLayout = (props: InferGetStaticPropsType<typeof getStaticProps>) => {
useClearCurrentComponent();
return (
<>
<IframeResizer license="GPLv3" src={props.url} style={{ width: '1px', minWidth: '100%' }} checkOrigin={false} />
Expand Down
6 changes: 0 additions & 6 deletions src/pages/[componentAccountId]/widget/[componentName].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useBosComponents } from '@/hooks/useBosComponents';
import { useGatewayEvents } from '@/hooks/useGatewayEvents';
import { useDefaultLayout } from '@/hooks/useLayout';
import { useSignInRedirect } from '@/hooks/useSignInRedirect';
import { useCurrentComponentStore } from '@/stores/current-component';
import type { NextPageWithLayout } from '@/utils/types';

type ComponentMetaPreview = {
Expand Down Expand Up @@ -92,7 +91,6 @@ export const getServerSideProps: GetServerSideProps<{

const ViewComponentPage: NextPageWithLayout = ({ meta }: InferGetServerSidePropsType<typeof getServerSideProps>) => {
const router = useRouter();
const setComponentSrc = useCurrentComponentStore((store) => store.setSrc);
const componentSrc = `${router.query.componentAccountId}/widget/${router.query.componentName}`;
const [componentProps, setComponentProps] = useState<Record<string, unknown>>({});
const { wallet, signedAccountId } = useContext(NearContext);
Expand All @@ -107,10 +105,6 @@ const ViewComponentPage: NextPageWithLayout = ({ meta }: InferGetServerSideProps
}
}, [signedAccountId, componentProps, requestAuthentication]);

useEffect(() => {
setComponentSrc(componentSrc);
}, [setComponentSrc, componentSrc]);

useEffect(() => {
setComponentProps(router.query);
}, [router.query]);
Expand Down
2 changes: 0 additions & 2 deletions src/pages/cookies/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { MetaTags } from '@/components/MetaTags';
import { VmComponent } from '@/components/vm/VmComponent';
import { useBosComponents } from '@/hooks/useBosComponents';
import { useClearCurrentComponent } from '@/hooks/useClearCurrentComponent';
import { useDefaultLayout } from '@/hooks/useLayout';
import type { NextPageWithLayout } from '@/utils/types';

const CookiesOverviewPage: NextPageWithLayout = () => {
useClearCurrentComponent();
const components = useBosComponents();

return (
Expand Down
6 changes: 0 additions & 6 deletions src/pages/embed/[accountId]/widget/[componentName].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@ import { privacyDomainName, termsDomainName } from '@/config';
import { useBosComponents } from '@/hooks/useBosComponents';
import { useGatewayEvents } from '@/hooks/useGatewayEvents';
import { useSimpleLayout } from '@/hooks/useLayout';
import { useCurrentComponentStore } from '@/stores/current-component';
import type { NextPageWithLayout } from '@/utils/types';

const EmbedComponentPage: NextPageWithLayout = () => {
const router = useRouter();
const components = useBosComponents();
const { wallet } = useContext(NearContext);
const setComponentSrc = useCurrentComponentStore((store) => store.setSrc);
const componentSrc = `${router.query.accountId}/widget/${router.query.componentName}`;
const [componentProps, setComponentProps] = useState<Record<string, unknown>>({});
const { emitGatewayEvent, shouldPassGatewayEventProps } = useGatewayEvents();

useEffect(() => {
setComponentSrc(componentSrc);
}, [setComponentSrc, componentSrc]);

useEffect(() => {
setComponentProps(router.query);
}, [router.query]);
Expand Down
3 changes: 0 additions & 3 deletions src/pages/flags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { SubmitHandler } from 'react-hook-form';
import { useForm } from 'react-hook-form';
import styled from 'styled-components';

import { useClearCurrentComponent } from '@/hooks/useClearCurrentComponent';
import { useFlags } from '@/hooks/useFlags';
import { useDefaultLayout } from '@/hooks/useLayout';
import type { NextPageWithLayout } from '@/utils/types';
Expand Down Expand Up @@ -42,8 +41,6 @@ const FlagsPage: NextPageWithLayout = () => {
const [flags, setFlags] = useFlags();
const form = useForm<FormData>();

useClearCurrentComponent();

useEffect(() => {
form.setValue('bosLoaderUrl', flags?.bosLoaderUrl || '');
}, [form, flags]);
Expand Down
20 changes: 10 additions & 10 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ export interface NearBlocks {
total_txns: string;
}

const Header = styled.div`
display: flex;
align-items: center;
justify-content: center;
min-height: 280px;
background-size: 54px;
padding: 16px 0px;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAGeSURBVHgB7doxTisxEAbgeY/mvQro6NiSDo6QkpJbcA2OwjWooKQMJ2DpKENJBV7FEYoBeQSIZr9PGk2cItWvsdfZnSBjKHVf6rnUbdD1N8g4K7VX6jhIEaycofaTIEWwcoam0yFYOYe179WiQ7Byhk8+8wnB6munlHNWgmD1tUGyFSYIVl8bJFcOCYLV106s/aBrJ2hNE+qo1GmpRanz2J5aB6X+x/oQv/l+FWz5E/O1iHU4pom0W/u0/uoZahnrgN2VGuv6Jpidl1+o2T5BznkrfKj9MdZT6l9836r+3k2pq1KXMVNz3gpbU7hOmj49AQ7x/lJ0WWsK5xhv2+AYkHQR29vbddDluqFvbNZPQZdg9S07az4gWH3tHZVgJQhW3xjb4XIZyo+Z3nffHN79CZ1gYuXc1b4KEytFsHLGptMhWDlj7Q9BimDlbJ4Ex4AftggHdwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIpXoUVLSWulnzoAAAAASUVORK5CYII=');
`;

const StyledCard = ({ href, title, description }: { href: string; title: string; description: string }) => {
return (
<Card style={{ padding: '2rem 1rem', border: 0, textDecoration: 'none' }} href={href}>
Expand Down Expand Up @@ -59,16 +69,6 @@ const HomePage: NextPageWithLayout = () => {
getAvrTx();
}, [nearStats]);

const Header = styled.div`
display: flex;
align-items: center;
justify-content: center;
min-height: 280px;
background-size: 54px;
padding: 16px 0px;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAGeSURBVHgB7doxTisxEAbgeY/mvQro6NiSDo6QkpJbcA2OwjWooKQMJ2DpKENJBV7FEYoBeQSIZr9PGk2cItWvsdfZnSBjKHVf6rnUbdD1N8g4K7VX6jhIEaycofaTIEWwcoam0yFYOYe179WiQ7Byhk8+8wnB6munlHNWgmD1tUGyFSYIVl8bJFcOCYLV106s/aBrJ2hNE+qo1GmpRanz2J5aB6X+x/oQv/l+FWz5E/O1iHU4pom0W/u0/uoZahnrgN2VGuv6Jpidl1+o2T5BznkrfKj9MdZT6l9836r+3k2pq1KXMVNz3gpbU7hOmj49AQ7x/lJ0WWsK5xhv2+AYkHQR29vbddDluqFvbNZPQZdg9S07az4gWH3tHZVgJQhW3xjb4XIZyo+Z3nffHN79CZ1gYuXc1b4KEytFsHLGptMhWDlj7Q9BimDlbJ4Ex4AftggHdwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIpXoUVLSWulnzoAAAAASUVORK5CYII=');
`;

return (
<Section grow="available">
<Flex stack gap="l" style={{ padding: deviceType === 'mobile' ? '0' : '0 var(--gap-l)' }}>
Expand Down
3 changes: 0 additions & 3 deletions src/pages/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import styled from 'styled-components';

import { NearContext } from '@/components/wallet-selector/WalletSelector';
import { signInContractId } from '@/config';
import { useClearCurrentComponent } from '@/hooks/useClearCurrentComponent';
import { useDefaultLayout } from '@/hooks/useLayout';
import { useSignInRedirect } from '@/hooks/useSignInRedirect';
import signedOutRoute from '@/utils/route/signedOutRoute';
Expand Down Expand Up @@ -46,8 +45,6 @@ const SignInPage: NextPageWithLayout = () => {
}
}, [searchParams, wallet]);

useClearCurrentComponent();

const onSubmit = handleSubmit(async (data) => {
if (!data.email || !wallet) return;

Expand Down
6 changes: 0 additions & 6 deletions src/pages/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import styled from 'styled-components';
import { NearContext } from '@/components/wallet-selector/WalletSelector';
import { network, signInContractId } from '@/config';
import { useDefaultLayout } from '@/hooks/useLayout';
import { useCurrentComponentStore } from '@/stores/current-component';
import type { NextPageWithLayout } from '@/utils/types';

import { accountAddressPatternNoSubaccount, emailPattern, getEmailId, isValidEmail } from '../utils/form-validation';
Expand All @@ -19,7 +18,6 @@ const ErrorText = styled.p`

const SignUpPage: NextPageWithLayout = () => {
const router = useRouter();
const setComponentSrc = useCurrentComponentStore((store) => store.setSrc);
const [isAccountAvailable, setIsAccountAvailable] = useState<boolean | null>(null);
const [isAccountValid, setIsAccountValid] = useState<boolean | null>(null);
const {
Expand All @@ -40,10 +38,6 @@ const SignUpPage: NextPageWithLayout = () => {
}
}, [router, signedAccountId]);

useEffect(() => {
setComponentSrc(null);
}, [setComponentSrc]);

const checkIsAccountAvailable = useCallback(async (desiredUsername: string) => {
// set to null to show loading
setIsAccountAvailable(null);
Expand Down
11 changes: 0 additions & 11 deletions src/stores/current-component.ts

This file was deleted.

0 comments on commit 62da1f1

Please sign in to comment.