Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez committed Jul 25, 2024
1 parent 6322787 commit e86c4f1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/sidebar-navigation/Search/AppsResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ interface Item {

interface AppsResultsProps {
item: Item;
setOpen: (open: boolean) => void;
setOpen?: (open: boolean) => void;
}

export const AppsResults: React.FC<AppsResultsProps> = ({ item, setOpen }) => {
const router = useRouter();
const redirect = (url: string) => {
router.push(url);
setOpen(false);
setOpen && setOpen(false);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ interface HighlightResult {

interface ComponentsResultsProps {
item: Item;
setOpen: (open: boolean) => void;
setOpen?: (open: boolean) => void;
}

export const ComponentsResults: React.FC<ComponentsResultsProps> = ({ item, setOpen }) => {
const router = useRouter();
const redirect = (url: string) => {
router.push(url);
setOpen(false);
setOpen && setOpen(false);
};
const defaultImage = 'bafkreifc4burlk35hxom3klq4mysmslfirj7slueenbj7ddwg7pc6ixomu';
const [imageSrc, setImageSrc] = useState(item?.image?.ipfs_cid || defaultImage);
Expand Down
4 changes: 2 additions & 2 deletions src/components/sidebar-navigation/Search/DocsResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ interface HighlightResultItem {

interface DocsResultsProps {
item: Item;
setOpen: (open: boolean) => void;
setOpen?: (open: boolean) => void;
}

export const DocsResults: React.FC<DocsResultsProps> = ({ item, setOpen }) => {
const router = useRouter();
const redirect = (url: string) => {
router.push(url);
setOpen(false);
setOpen && setOpen(false);
};
const convertUrl = (url: string) => url.replace(/^https:\/\/docs\.near\.org\/(.+)$/, '/documentation/$1');

Expand Down
16 changes: 15 additions & 1 deletion src/hooks/useGatewayEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type PinnedAppsGatewayEvent = {
action: 'FEATURE_ENABLED' | 'PINNED' | 'UNPINNED';
};

type GatewayEvent = PinnedAppsGatewayEvent;

const COMPONENT_AUTHOR_ID_WHITELIST = ['near', 'discom.testnet', 'discom-dev.testnet'];

export function useGatewayEvents() {
Expand All @@ -29,6 +31,18 @@ export function useGatewayEvents() {
[modifyPinnedApps, sidebarLayoutEnabled],
);

const emitGatewayEvent = useCallback(
(event: GatewayEvent) => {
switch (event.type) {
case 'PINNED_APPS':
return handlePinnedAppsEvent(event);
default:
console.error('Unimplemented gateway event recorded:', event);
}
},
[handlePinnedAppsEvent],
);

const shouldPassGatewayEventProps = useCallback((componentAuthorId: string) => {
/*
When rendering components we might not trust (eg: pages/[componentAccountId]/widget/[componentName].tsx),
Expand All @@ -43,5 +57,5 @@ export function useGatewayEvents() {
to only expose methods that rely on useCallback() to reduce re-renders for the VM.
*/

return { shouldPassGatewayEventProps };
return { emitGatewayEvent, shouldPassGatewayEventProps };
}

0 comments on commit e86c4f1

Please sign in to comment.