Skip to content

Commit

Permalink
Merge pull request #1318 from near/fixes
Browse files Browse the repository at this point in the history
feat: remove server side load
  • Loading branch information
gagdiez authored Oct 9, 2024
2 parents 62da1f1 + de176cc commit 7b27ccc
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 185 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.3",
"react-singleton-hook": "^3.4.0",
"remark": "^14.0.3",
"rudder-sdk-js": "^2.48.6",
"strip-markdown": "^5.0.1",
"styled-components": "^5.3.11",
"typescript": "^5.4.5",
"wagmi": "^2.12.17",
Expand Down
54 changes: 8 additions & 46 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/components/sidebar-navigation/UserDropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const UserDropdownMenu = ({ collapsed }: Props) => {
method: 'storage_balance_of',
args: { account_id: signedAccountId },
});
setAvailableStorage(BigInt(storage.available) / BigInt(10 ** 19));
if (storage) setAvailableStorage(BigInt(storage.available) / BigInt(10 ** 19));
}

if (!wallet || !signedAccountId) return;
Expand Down
56 changes: 56 additions & 0 deletions src/pages/[accountId]/widget/[componentName].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { useRouter } from 'next/router';
import { useContext, useEffect, useState } from 'react';

import { RootContentContainer } from '@/components/RootContentContainer';
import { VmComponent } from '@/components/vm/VmComponent';
import { NearContext } from '@/components/wallet-selector/WalletSelector';
import { privacyDomainName, termsDomainName } from '@/config';
import { useBosComponents } from '@/hooks/useBosComponents';
import { useGatewayEvents } from '@/hooks/useGatewayEvents';
import { useDefaultLayout } from '@/hooks/useLayout';
import { useSignInRedirect } from '@/hooks/useSignInRedirect';
import type { NextPageWithLayout } from '@/utils/types';

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

useEffect(() => {
const { requestAuth, createAccount } = componentProps;
if (requestAuth && !signedAccountId) {
requestAuthentication(!!createAccount);
}
}, [signedAccountId, componentProps, requestAuthentication]);

useEffect(() => {
setComponentProps(router.query);
}, [router.query]);

return (
<RootContentContainer>
<VmComponent
key={components.wrapper}
src={components.wrapper}
props={{
emitGatewayEvent: shouldPassGatewayEventProps(router.query.componentAccountId as string)
? emitGatewayEvent
: undefined,
logOut: wallet?.signOut,
targetProps: componentProps,
targetComponent: componentSrc,
termsDomainName,
privacyDomainName,
}}
/>
</RootContentContainer>
);
};

ViewComponentPage.getLayout = useDefaultLayout;

export default ViewComponentPage;
136 changes: 0 additions & 136 deletions src/pages/[componentAccountId]/widget/[componentName].tsx

This file was deleted.

0 comments on commit 7b27ccc

Please sign in to comment.