From ea1a9a1bf13cae9a0467358a846cad37d4406cdf Mon Sep 17 00:00:00 2001 From: Karlen9 <80678705+Karlen9@users.noreply.github.com> Date: Wed, 15 Jan 2025 14:48:06 +0300 Subject: [PATCH 1/7] feat: sidebar stream iframe --- .../lib/common/SideMenu/SideMenuNav/index.tsx | 2 ++ packages/lib/utils/helpers.ts | 4 ++++ packages/smol/components/Wallet/index.tsx | 1 + packages/smol/pages/_app.tsx | 22 ++++++++++++++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/lib/common/SideMenu/SideMenuNav/index.tsx b/packages/lib/common/SideMenu/SideMenuNav/index.tsx index 7d497a69..8593e6f8 100644 --- a/packages/lib/common/SideMenu/SideMenuNav/index.tsx +++ b/packages/lib/common/SideMenu/SideMenuNav/index.tsx @@ -10,6 +10,7 @@ import {LinkOrDiv} from '@lib/common/LinkOrDiv'; import {useIsMounted} from '@lib/hooks/useIsMounted'; import {IconChevron} from '@lib/icons/IconChevron'; import {CurtainContent} from '@lib/primitives/Curtain'; +import {isInIframe} from '@lib/utils/helpers'; import {PLAUSIBLE_EVENTS} from '@lib/utils/plausible'; export type TSideMenuItem = { @@ -42,6 +43,7 @@ function NavItem({
( >>>>>> Stashed changes import {IconCheck} from '@lib/icons/IconCheck'; import {IconCircleCross} from '@lib/icons/IconCircleCross'; import {IconClone} from '@lib/icons/IconClone'; @@ -70,6 +81,11 @@ const MENU = [ icon: } ] + }, + { + href: 'https://v1.smold.app/stream', + label: 'Stream', + icon: } // { // href: '/apps/earn', @@ -77,12 +93,6 @@ const MENU = [ // isDisabled: true, // icon: // }, - // { - // href: '/apps/stream', - // label: 'Stream', - // isDisabled: true, - // icon: - // } ]; function MyApp(props: AppProps): ReactElement { From 8427b3cfd0bee584fe260de0562676ba57a07bb3 Mon Sep 17 00:00:00 2001 From: Karlen9 <80678705+Karlen9@users.noreply.github.com> Date: Wed, 15 Jan 2025 14:50:30 +0300 Subject: [PATCH 2/7] fix: conflicts --- packages/smol/pages/_app.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/smol/pages/_app.tsx b/packages/smol/pages/_app.tsx index 56b2fe8c..13ac90d5 100755 --- a/packages/smol/pages/_app.tsx +++ b/packages/smol/pages/_app.tsx @@ -8,9 +8,6 @@ import {WithFonts} from '@lib/common/WithFonts'; import {IndexedDB} from '@lib/contexts/useIndexedDB'; import {WithPopularTokens} from '@lib/contexts/usePopularTokens'; import {WithPrices} from '@lib/contexts/usePrices'; -<<<<<<< Updated upstream -import {IconAppAddressBook, IconAppDisperse, IconAppRevoke, IconAppSend, IconAppSwap} from '@lib/icons/IconApps'; -======= import { IconAppAddressBook, IconAppDisperse, @@ -19,7 +16,6 @@ import { IconAppStream, IconAppSwap } from '@lib/icons/IconApps'; ->>>>>>> Stashed changes import {IconCheck} from '@lib/icons/IconCheck'; import {IconCircleCross} from '@lib/icons/IconCircleCross'; import {IconClone} from '@lib/icons/IconClone'; From ac7d9b512a653078ad10aa28c8e174734461e7b8 Mon Sep 17 00:00:00 2001 From: Karlen9 <80678705+Karlen9@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:07:04 +0300 Subject: [PATCH 3/7] chore: target change --- packages/lib/common/SideMenu/SideMenuNav/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/lib/common/SideMenu/SideMenuNav/index.tsx b/packages/lib/common/SideMenu/SideMenuNav/index.tsx index 8593e6f8..7d8fd21d 100644 --- a/packages/lib/common/SideMenu/SideMenuNav/index.tsx +++ b/packages/lib/common/SideMenu/SideMenuNav/index.tsx @@ -38,12 +38,14 @@ function NavItem({ hasSubmenu, isDisabled = false }: TNavItemProps): ReactElement { + const target = isInIframe() ? '_self' : href === 'https://v1.smold.app/stream' ? '_blank' : '_self'; + return (
Date: Wed, 15 Jan 2025 17:52:22 +0300 Subject: [PATCH 4/7] feat: target selt for safe --- .../lib/common/SideMenu/SideMenuNav/index.tsx | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/lib/common/SideMenu/SideMenuNav/index.tsx b/packages/lib/common/SideMenu/SideMenuNav/index.tsx index 7d8fd21d..30567a6f 100644 --- a/packages/lib/common/SideMenu/SideMenuNav/index.tsx +++ b/packages/lib/common/SideMenu/SideMenuNav/index.tsx @@ -1,6 +1,7 @@ import {cloneElement, Fragment, type ReactElement, useCallback, useEffect, useState} from 'react'; import Link from 'next/link'; import {usePathname} from 'next/navigation'; +import {useRouter} from 'next/router'; import {usePlausible} from 'next-plausible'; import {motion} from 'framer-motion'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; @@ -29,6 +30,7 @@ type TNavItemProps = { isDisabled?: boolean; onClick?: () => void; }; + function NavItem({ label, href, @@ -38,7 +40,27 @@ function NavItem({ hasSubmenu, isDisabled = false }: TNavItemProps): ReactElement { - const target = isInIframe() ? '_self' : href === 'https://v1.smold.app/stream' ? '_blank' : '_self'; + const router = useRouter(); + const target = isInIframe() + ? '_self' + : !isInIframe() && href === 'https://v1.smold.app/stream' + ? '_self' + : '_blank'; + + /****************************************************************************** + ** Handle navigation within Safe app context by updating the appUrl query param + ** while preserving the existing Safe context and other query parameters + *****************************************************************************/ + const goToSafeApp = (): void => { + const url = { + pathname: router.pathname, + query: { + ...router.query, + appUrl: href + } + }; + router.replace(url); + }; return ( @@ -46,7 +68,7 @@ function NavItem({ href={hasSubmenu ? href : href} isDisabled={isDisabled} target={target} - onClick={onClick}> + onClick={href === 'https://v1.smold.app/stream' && isInIframe() ? goToSafeApp : onClick}>
Date: Wed, 15 Jan 2025 17:55:18 +0300 Subject: [PATCH 5/7] chore: codefactor --- .../lib/common/SideMenu/SideMenuNav/index.tsx | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/lib/common/SideMenu/SideMenuNav/index.tsx b/packages/lib/common/SideMenu/SideMenuNav/index.tsx index 30567a6f..a88306c3 100644 --- a/packages/lib/common/SideMenu/SideMenuNav/index.tsx +++ b/packages/lib/common/SideMenu/SideMenuNav/index.tsx @@ -14,6 +14,8 @@ import {CurtainContent} from '@lib/primitives/Curtain'; import {isInIframe} from '@lib/utils/helpers'; import {PLAUSIBLE_EVENTS} from '@lib/utils/plausible'; +import type {NextRouter} from 'next/router'; + export type TSideMenuItem = { href: string; label: string; @@ -31,6 +33,21 @@ type TNavItemProps = { onClick?: () => void; }; +/****************************************************************************** + ** Handle navigation within Safe app context by updating the appUrl query param + ** while preserving the existing Safe context and other query parameters + *****************************************************************************/ +const goToSafeApp = (router: NextRouter, href: string): void => { + const url = { + pathname: router.pathname, + query: { + ...router.query, + appUrl: href + } + }; + router.replace(url); +}; + function NavItem({ label, href, @@ -47,28 +64,15 @@ function NavItem({ ? '_self' : '_blank'; - /****************************************************************************** - ** Handle navigation within Safe app context by updating the appUrl query param - ** while preserving the existing Safe context and other query parameters - *****************************************************************************/ - const goToSafeApp = (): void => { - const url = { - pathname: router.pathname, - query: { - ...router.query, - appUrl: href - } - }; - router.replace(url); - }; - return ( + onClick={ + href === 'https://v1.smold.app/stream' && isInIframe() ? () => goToSafeApp(router, href) : onClick + }>
Date: Wed, 15 Jan 2025 18:19:18 +0300 Subject: [PATCH 6/7] chore: codefactor --- .../lib/common/SideMenu/SideMenuNav/index.tsx | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/packages/lib/common/SideMenu/SideMenuNav/index.tsx b/packages/lib/common/SideMenu/SideMenuNav/index.tsx index a88306c3..179f2cc7 100644 --- a/packages/lib/common/SideMenu/SideMenuNav/index.tsx +++ b/packages/lib/common/SideMenu/SideMenuNav/index.tsx @@ -1,4 +1,4 @@ -import {cloneElement, Fragment, type ReactElement, useCallback, useEffect, useState} from 'react'; +import {cloneElement, Fragment, type ReactElement, useCallback, useEffect, useMemo, useState} from 'react'; import Link from 'next/link'; import {usePathname} from 'next/navigation'; import {useRouter} from 'next/router'; @@ -14,8 +14,6 @@ import {CurtainContent} from '@lib/primitives/Curtain'; import {isInIframe} from '@lib/utils/helpers'; import {PLAUSIBLE_EVENTS} from '@lib/utils/plausible'; -import type {NextRouter} from 'next/router'; - export type TSideMenuItem = { href: string; label: string; @@ -33,21 +31,6 @@ type TNavItemProps = { onClick?: () => void; }; -/****************************************************************************** - ** Handle navigation within Safe app context by updating the appUrl query param - ** while preserving the existing Safe context and other query parameters - *****************************************************************************/ -const goToSafeApp = (router: NextRouter, href: string): void => { - const url = { - pathname: router.pathname, - query: { - ...router.query, - appUrl: href - } - }; - router.replace(url); -}; - function NavItem({ label, href, @@ -58,11 +41,33 @@ function NavItem({ isDisabled = false }: TNavItemProps): ReactElement { const router = useRouter(); - const target = isInIframe() - ? '_self' - : !isInIframe() && href === 'https://v1.smold.app/stream' - ? '_self' - : '_blank'; + const target = useMemo(() => { + if (isInIframe()) { + return '_self'; + } + if (!isInIframe()) { + if (href === 'https://v1.smold.app/stream') { + return '_blank'; + } + return '_self'; + } + return '_self'; + }, [href]); + + /****************************************************************************** + ** Handle navigation within Safe app context by updating the appUrl query param + ** while preserving the existing Safe context and other query parameters + *****************************************************************************/ + const goToSafeApp = useCallback(() => { + const url = { + pathname: router.pathname, + query: { + ...router.query, + appUrl: href + } + }; + router.replace(url); + }, [href, router]); return ( @@ -70,9 +75,7 @@ function NavItem({ href={hasSubmenu ? href : href} isDisabled={isDisabled} target={target} - onClick={ - href === 'https://v1.smold.app/stream' && isInIframe() ? () => goToSafeApp(router, href) : onClick - }> + onClick={href === 'https://v1.smold.app/stream' && isInIframe() ? goToSafeApp : onClick}>
Date: Wed, 15 Jan 2025 20:22:52 +0300 Subject: [PATCH 7/7] chore: target change --- .../lib/common/SideMenu/SideMenuNav/index.tsx | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/lib/common/SideMenu/SideMenuNav/index.tsx b/packages/lib/common/SideMenu/SideMenuNav/index.tsx index 179f2cc7..7eac739c 100644 --- a/packages/lib/common/SideMenu/SideMenuNav/index.tsx +++ b/packages/lib/common/SideMenu/SideMenuNav/index.tsx @@ -1,4 +1,4 @@ -import {cloneElement, Fragment, type ReactElement, useCallback, useEffect, useMemo, useState} from 'react'; +import {cloneElement, Fragment, type ReactElement, useCallback, useEffect, useState} from 'react'; import Link from 'next/link'; import {usePathname} from 'next/navigation'; import {useRouter} from 'next/router'; @@ -41,18 +41,6 @@ function NavItem({ isDisabled = false }: TNavItemProps): ReactElement { const router = useRouter(); - const target = useMemo(() => { - if (isInIframe()) { - return '_self'; - } - if (!isInIframe()) { - if (href === 'https://v1.smold.app/stream') { - return '_blank'; - } - return '_self'; - } - return '_self'; - }, [href]); /****************************************************************************** ** Handle navigation within Safe app context by updating the appUrl query param @@ -74,7 +62,7 @@ function NavItem({