Skip to content

Commit

Permalink
chore: refactor helpers and handlers, fix bugs. (#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
sasicodes authored Nov 5, 2023
1 parent f5969ee commit 5fa420f
Show file tree
Hide file tree
Showing 25 changed files with 93 additions and 82 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/components/Common/MirrorVideo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SIGN_IN_REQUIRED
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getSignature,
Tower
Expand Down Expand Up @@ -48,7 +48,7 @@ const MirrorVideo: FC<Props> = ({ video, children, onMirrorSuccess }) => {

const activeProfile = useProfileStore((state) => state.activeProfile)
const { canUseLensManager, canBroadcast } =
checkDispatcherPermissions(activeProfile)
checkLensManagerPermissions(activeProfile)

const onError = (error: CustomErrorWithData) => {
toast.error(error?.data?.message ?? error?.message ?? ERROR_MESSAGE)
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Common/PostLinkModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
TAPE_WEBSITE_URL
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getOpenActionNftMetadata,
getProfile,
Expand Down Expand Up @@ -76,7 +76,7 @@ const PostLinkModal: FC<Props> = ({ show, setShow }) => {
(state) => state.activeProfile
) as Profile
const { canUseLensManager, canBroadcast } =
checkDispatcherPermissions(activeProfile)
checkLensManagerPermissions(activeProfile)

const {
register,
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Common/VideoCard/VideoOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
TAPE_APP_ID
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getIsIPFSUrl,
getMetadataCid,
Expand Down Expand Up @@ -76,7 +76,7 @@ const VideoOptions: FC<Props> = ({ video, variant = 'ghost', children }) => {
const { cache } = useApolloClient()
const activeProfile = useProfileStore((state) => state.activeProfile)
const { canUseLensManager, canBroadcast } =
checkDispatcherPermissions(activeProfile)
checkLensManagerPermissions(activeProfile)

const isVideoOwner = activeProfile?.id === video?.by?.id
const pinnedVideoId = getValueFromKeyInAttributes(
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from '@tape.xyz/constants'
import {
canUploadedToIpfs,
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getProfile,
getSignature,
Expand Down Expand Up @@ -82,7 +82,7 @@ const CreateSteps = () => {
const router = useRouter()
const handleWrongNetwork = useHandleWrongNetwork()
const { canUseLensManager, canBroadcast } =
checkDispatcherPermissions(activeProfile)
checkLensManagerPermissions(activeProfile)

const degreesOfSeparation = uploadedVideo.referenceModule
?.degreesOfSeparationReferenceModule?.degreesOfSeparation as number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import ToggleDispatcher from '@components/Settings/Manager/Dispatcher/ToggleDispatcher'
import ToggleLensManager from '@components/Settings/Manager/LensManager/ToggleLensManager'
import SignalWaveGraphic from '@components/UIElements/SignalWaveGraphic'
import useProfileStore from '@lib/store/profile'
import { Flex } from '@radix-ui/themes'
import { TAPE_APP_NAME } from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
getIsProfileOwner
} from '@tape.xyz/generic'
import React from 'react'
import { useAccount } from 'wagmi'

const DispatcherAlert = () => {
const LensManagerAlert = () => {
const { address } = useAccount()
const activeProfile = useProfileStore((state) => state.activeProfile)

const isOwner = activeProfile && getIsProfileOwner(activeProfile, address)
const { canUseLensManager } = checkDispatcherPermissions(activeProfile)
const { canUseLensManager } = checkLensManagerPermissions(activeProfile)

const getDescription = () => {
return `Enable dispatcher to interact with ${TAPE_APP_NAME} without signing any of your transactions.`
return `Enable your Lens manager for seamless interaction with ${TAPE_APP_NAME}, allowing for faster and easier transactions without the need for signing.`
}

if (!activeProfile || canUseLensManager || !isOwner) {
Expand All @@ -34,7 +34,7 @@ const DispatcherAlert = () => {
{getDescription()}
</p>
<Flex>
<ToggleDispatcher />
<ToggleLensManager />
</Flex>
</div>

Expand All @@ -43,4 +43,4 @@ const DispatcherAlert = () => {
)
}

export default DispatcherAlert
export default LensManagerAlert
4 changes: 2 additions & 2 deletions apps/web/src/components/Home/TopSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import HorizantalScroller from '@components/Common/HorizantalScroller'
import useProfileStore from '@lib/store/profile'
import React, { useRef } from 'react'

import DispatcherAlert from './DispatcherAlert'
import GitcoinAlert from './GitcoinAlert'
import LatestBytes from './LatestBytes'
import LensManagerAlert from './LensManagerAlert'
import WelcomeAlert from './WelcomeAlert'

const TopSection = () => {
Expand All @@ -24,7 +24,7 @@ const TopSection = () => {
>
{!activeProfile?.id && <WelcomeAlert />}
<GitcoinAlert />
<DispatcherAlert />
<LensManagerAlert />
<LatestBytes />
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/BasicInfo/Follow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
SIGN_IN_REQUIRED
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getProfile,
getSignature,
Expand Down Expand Up @@ -40,7 +40,7 @@ const Follow: FC<Props> = ({ profile, onSubscribe, size = '2' }) => {
const [loading, setLoading] = useState(false)
const { activeProfile } = useProfileStore()
const { canUseLensManager, canBroadcast } =
checkDispatcherPermissions(activeProfile)
checkLensManagerPermissions(activeProfile)
const handleWrongNetwork = useHandleWrongNetwork()

const { lensHubOnchainSigNonce, setLensHubOnchainSigNonce } = useNonceStore()
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/BasicInfo/SuperFollow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SIGN_IN_REQUIRED
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getProfile,
getSignature,
Expand Down Expand Up @@ -51,7 +51,7 @@ const SuperFollow: FC<Props> = ({ profile, onJoin, size = '2' }) => {

const { activeProfile } = useProfileStore()
const { lensHubOnchainSigNonce, setLensHubOnchainSigNonce } = useNonceStore()
const { canBroadcast } = checkDispatcherPermissions(activeProfile)
const { canBroadcast } = checkLensManagerPermissions(activeProfile)

const onError = (error: CustomErrorWithData) => {
toast.error(error?.data?.message ?? error?.message ?? ERROR_MESSAGE)
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/BasicInfo/UnFollow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SIGN_IN_REQUIRED
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getProfile,
getSignature,
Expand Down Expand Up @@ -42,7 +42,7 @@ const UnFollow: FC<Props> = ({ profile, onUnSubscribe, size = '2' }) => {
const { activeProfile } = useProfileStore()
const { lensHubOnchainSigNonce, setLensHubOnchainSigNonce } = useNonceStore()
const { canUseLensManager, canBroadcast } =
checkDispatcherPermissions(activeProfile)
checkLensManagerPermissions(activeProfile)

const handleWrongNetwork = useHandleWrongNetwork()

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/BasicInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
TAPE_WEBSITE_URL
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
getProfile,
getSignature
} from '@tape.xyz/generic'
Expand Down Expand Up @@ -63,7 +63,7 @@ const BasicInfo: FC<Props> = ({ profile }) => {

const { lensHubOnchainSigNonce, setLensHubOnchainSigNonce } = useNonceStore()
const { activeProfile } = useProfileStore()
const { canBroadcast } = checkDispatcherPermissions(activeProfile)
const { canBroadcast } = checkLensManagerPermissions(activeProfile)

const hasOnChainId =
profile.onchainIdentity?.ens?.name ||
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Profile/Tabs/PinnedVideo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
TAPE_APP_ID
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getIsSensitiveContent,
getProfileCoverPicture,
Expand Down Expand Up @@ -61,7 +61,7 @@ const PinnedVideo: FC<Props> = ({ id }) => {
const { activeProfile } = useProfileStore()
const handleWrongNetwork = useHandleWrongNetwork()
const { canUseLensManager, canBroadcast } =
checkDispatcherPermissions(activeProfile)
checkLensManagerPermissions(activeProfile)

const { data, error, loading } = usePublicationQuery({
variables: {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Settings/BasicInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
TAPE_WEBSITE_URL
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getProfile,
getProfileCoverPicture,
Expand Down Expand Up @@ -95,7 +95,7 @@ const BasicInfo = ({ profile }: Props) => {
const [uploading, setUploading] = useState({ pfp: false, cover: false })
const handleWrongNetwork = useHandleWrongNetwork()
const { canUseLensManager, canBroadcast } =
checkDispatcherPermissions(profile)
checkLensManagerPermissions(profile)

const {
register,
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Settings/Blocked/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
SIGN_IN_REQUIRED
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
getProfile,
getProfileCoverPicture,
getProfilePicture,
Expand Down Expand Up @@ -49,7 +49,7 @@ const List = () => {
const { activeProfile } = useProfileStore()
const { lensHubOnchainSigNonce, setLensHubOnchainSigNonce } = useNonceStore()
const { cache } = useApolloClient()
const { canBroadcast } = checkDispatcherPermissions(activeProfile)
const { canBroadcast } = checkLensManagerPermissions(activeProfile)
const handleWrongNetwork = useHandleWrongNetwork()

const onError = (error: CustomErrorWithData) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
REQUESTING_SIGNATURE_MESSAGE
} from '@tape.xyz/constants'
import {
checkDispatcherPermissions,
checkLensManagerPermissions,
EVENTS,
getSignature,
Tower
Expand All @@ -26,13 +26,13 @@ import React, { useEffect, useState } from 'react'
import toast from 'react-hot-toast'
import { useContractWrite, useSignTypedData } from 'wagmi'

const ToggleDispatcher = () => {
const ToggleLensManager = () => {
const [loading, setLoading] = useState(false)

const { activeProfile, setActiveProfile } = useProfileStore()
const { lensHubOnchainSigNonce, setLensHubOnchainSigNonce } = useNonceStore()
const handleWrongNetwork = useHandleWrongNetwork()
const { canBroadcast } = checkDispatcherPermissions(activeProfile)
const { canBroadcast } = checkLensManagerPermissions(activeProfile)

const isLensManagerEnabled = activeProfile?.signless || false

Expand Down Expand Up @@ -73,13 +73,13 @@ const ToggleDispatcher = () => {
useEffect(() => {
if (indexed) {
toast.success(
`Dispatcher ${isLensManagerEnabled ? `disabled` : `enabled`}`
`Lens Manager ${isLensManagerEnabled ? `disabled` : `enabled`}`
)
const channel = { ...activeProfile }
channel.signless = isLensManagerEnabled ? false : true
setActiveProfile(channel as Profile)
setLoading(false)
Tower.track(EVENTS.DISPATCHER.TOGGLE)
Tower.track(EVENTS.MANAGER.TOGGLE, { enabled: channel.signless })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [indexed])
Expand Down Expand Up @@ -153,9 +153,9 @@ const ToggleDispatcher = () => {
disabled={loading}
>
{loading && <Loader size="sm" />}
{getButtonText()} dispatcher
{getButtonText()}
</Button>
)
}

export default ToggleDispatcher
export default ToggleLensManager
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ import useProfileStore from '@lib/store/profile'
import { TAPE_APP_NAME } from '@tape.xyz/constants'
import React from 'react'

import ToggleDispatcher from './ToggleDispatcher'
import ToggleLensManager from './ToggleLensManager'

const DispatcherPermissions = () => {
const LensManager = () => {
const activeProfile = useProfileStore((state) => state.activeProfile)

const getDescription = () => {
if (!activeProfile?.signless) {
return `Enable your dispatcher to the latest version for better, faster signless transactions.`
return `Enable your Lens manager for seamless interaction with ${TAPE_APP_NAME}, allowing for faster and easier transactions without the need for signing.`
}
return `Dispacher helps interact with ${TAPE_APP_NAME} without signing any of your transactions.`
return `Lens manager helps interact with ${TAPE_APP_NAME} without signing any of your transactions.`
}

return (
<div className="flex flex-wrap items-center justify-between">
<div className="mb-2 space-y-2">
<h1 className="text-brand-400 text-xl font-bold">Dispatcher</h1>
<h1 className="text-brand-400 text-xl font-bold">Lens Manager</h1>
<p className="opacity-80">{getDescription()}</p>
</div>
<div className="mt-3 flex justify-end">
<ToggleDispatcher />
<ToggleLensManager />
</div>
</div>
)
}

export default DispatcherPermissions
export default LensManager
Loading

3 comments on commit 5fa420f

@vercel
Copy link

@vercel vercel bot commented on 5fa420f Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

embed – ./apps/embed

embed-tapexyz.vercel.app
embed-git-main-tapexyz.vercel.app
embed.tape.xyz
embed.lenstube.xyz

@vercel
Copy link

@vercel vercel bot commented on 5fa420f Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./apps/web

web-tapexyz.vercel.app
tape.xyz
web-git-main-tapexyz.vercel.app
www.tape.xyz

@vercel
Copy link

@vercel vercel bot commented on 5fa420f Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

api – ./apps/api

api-tapexyz.vercel.app
api.tape.xyz
api-git-main-tapexyz.vercel.app
api.lenstube.xyz

Please sign in to comment.