From 4348eafeab1cc64018e13faafec00be810c3b802 Mon Sep 17 00:00:00 2001 From: Andrei Homentcovschi Date: Fri, 11 Nov 2022 00:40:21 -0800 Subject: [PATCH 1/4] Added shop collects button --- codegen.yml | 2 +- .../Watch/CollectVideo/CollectModal.tsx | 67 ++++++++++--------- src/components/Watch/CollectVideo/index.tsx | 21 ++++++ 3 files changed, 59 insertions(+), 31 deletions(-) diff --git a/codegen.yml b/codegen.yml index a1589fce6..9e7ea2fd6 100644 --- a/codegen.yml +++ b/codegen.yml @@ -1,4 +1,4 @@ -schema: https://api-mumbai.lens.dev +schema: https://api.lens.dev documents: "**/*.graphql" hooks: afterOneFileWrite: diff --git a/src/components/Watch/CollectVideo/CollectModal.tsx b/src/components/Watch/CollectVideo/CollectModal.tsx index fda790655..087fd5ee9 100644 --- a/src/components/Watch/CollectVideo/CollectModal.tsx +++ b/src/components/Watch/CollectVideo/CollectModal.tsx @@ -30,6 +30,7 @@ type Props = { fetchingCollectModule: boolean collectModule: LenstubeCollectModule collectNow: () => void + shopCollects: () => void } const CollectModal: FC = ({ @@ -37,6 +38,7 @@ const CollectModal: FC = ({ setShowModal, video, collectNow, + shopCollects, collecting, collectModule, fetchingCollectModule @@ -177,37 +179,42 @@ const CollectModal: FC = ({ ) : null}
- {isAllowed ? ( - collectModule?.followerOnly && !video.profile.isFollowedByMe ? ( -
- -
- Only {isMembershipActive ? 'Members' : 'Subscribers'}{' '} - can collect this publication -
-
-
- ) : balanceLoading && !haveEnoughBalance ? ( -
- -
- ) : haveEnoughBalance ? ( - + + {isAllowed ? ( + collectModule?.followerOnly && !video.profile.isFollowedByMe ? ( +
+ +
+ Only {isMembershipActive ? 'Members' : 'Subscribers'}{' '} + can collect this publication +
+
+
+ ) : balanceLoading && !haveEnoughBalance ? ( +
+ +
+ ) : haveEnoughBalance ? ( + + ) : ( + + ) ) : ( - - ) - ) : ( - - )} + + )} + +
) : ( diff --git a/src/components/Watch/CollectVideo/index.tsx b/src/components/Watch/CollectVideo/index.tsx index 48d6b1809..791ed7e7d 100644 --- a/src/components/Watch/CollectVideo/index.tsx +++ b/src/components/Watch/CollectVideo/index.tsx @@ -157,6 +157,26 @@ const CollectVideo: FC = ({ video, variant = 'primary' }) => { }) } + const shopCollects = () => { + if (!video) { + return; + } + var pubId = ''; + if (video.__typename === 'Mirror') { + if (!video.mirrorOf) { + return; + } + pubId = video.mirrorOf.id; + } else { + pubId = video.id; + } + const decimalProfileId = parseInt(pubId.split('-')[0], 16); + const decimalPubId = parseInt(pubId.split('-')[1], 16); + const marketplacePublicationId = decimalProfileId + '_' + decimalPubId; + const marketplaceUrl = 'http://lensport.io/p/' + marketplacePublicationId; + window.open(marketplaceUrl); + } + const onClickCollect = () => { if (!selectedChannelId) return toast.error(SIGN_IN_REQUIRED_MESSAGE) return setShowCollectModal(true) @@ -182,6 +202,7 @@ const CollectVideo: FC = ({ video, variant = 'primary' }) => { showModal={showCollectModal} setShowModal={setShowCollectModal} collectNow={collectNow} + shopCollects={shopCollects} collecting={loading} collectModule={collectModule} fetchingCollectModule={fetchingCollectModule} From 77f778a3c5409bf8dd5e21a4b6284752cf1577b9 Mon Sep 17 00:00:00 2001 From: Andrei Homentcovschi Date: Fri, 11 Nov 2022 09:54:40 -0800 Subject: [PATCH 2/4] Added shop collects button --- codegen.yml | 2 +- .../Watch/CollectVideo/CollectModal.tsx | 7 +++---- src/components/Watch/CollectVideo/index.tsx | 20 +++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/codegen.yml b/codegen.yml index 9e7ea2fd6..a1589fce6 100644 --- a/codegen.yml +++ b/codegen.yml @@ -1,4 +1,4 @@ -schema: https://api.lens.dev +schema: https://api-mumbai.lens.dev documents: "**/*.graphql" hooks: afterOneFileWrite: diff --git a/src/components/Watch/CollectVideo/CollectModal.tsx b/src/components/Watch/CollectVideo/CollectModal.tsx index 087fd5ee9..04792c45a 100644 --- a/src/components/Watch/CollectVideo/CollectModal.tsx +++ b/src/components/Watch/CollectVideo/CollectModal.tsx @@ -181,7 +181,8 @@ const CollectModal: FC = ({
{isAllowed ? ( - collectModule?.followerOnly && !video.profile.isFollowedByMe ? ( + collectModule?.followerOnly && + !video.profile.isFollowedByMe ? (
@@ -211,9 +212,7 @@ const CollectModal: FC = ({ } /> )} - +
diff --git a/src/components/Watch/CollectVideo/index.tsx b/src/components/Watch/CollectVideo/index.tsx index 791ed7e7d..46a132962 100644 --- a/src/components/Watch/CollectVideo/index.tsx +++ b/src/components/Watch/CollectVideo/index.tsx @@ -159,22 +159,22 @@ const CollectVideo: FC = ({ video, variant = 'primary' }) => { const shopCollects = () => { if (!video) { - return; + return } - var pubId = ''; + var pubId = '' if (video.__typename === 'Mirror') { if (!video.mirrorOf) { - return; + return } - pubId = video.mirrorOf.id; + pubId = video.mirrorOf.id } else { - pubId = video.id; + pubId = video.id } - const decimalProfileId = parseInt(pubId.split('-')[0], 16); - const decimalPubId = parseInt(pubId.split('-')[1], 16); - const marketplacePublicationId = decimalProfileId + '_' + decimalPubId; - const marketplaceUrl = 'http://lensport.io/p/' + marketplacePublicationId; - window.open(marketplaceUrl); + const decimalProfileId = parseInt(pubId.split('-')[0], 16) + const decimalPubId = parseInt(pubId.split('-')[1], 16) + const marketplacePublicationId = decimalProfileId + '_' + decimalPubId + const marketplaceUrl = 'http://lensport.io/p/' + marketplacePublicationId + window.open(marketplaceUrl) } const onClickCollect = () => { From 68a865636efee71283bd134e6f179b84fc5382cd Mon Sep 17 00:00:00 2001 From: Andrei Homentcovschi Date: Fri, 11 Nov 2022 23:34:29 -0800 Subject: [PATCH 3/4] Added LensPort marketplace link. Hides shop button when no collects. Reformatting pubId to be cleaner --- .../Watch/CollectVideo/CollectModal.tsx | 67 +++++++++---------- src/components/Watch/CollectVideo/index.tsx | 15 ++--- src/utils/constants.ts | 1 + 3 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/components/Watch/CollectVideo/CollectModal.tsx b/src/components/Watch/CollectVideo/CollectModal.tsx index 04792c45a..b1d4820db 100644 --- a/src/components/Watch/CollectVideo/CollectModal.tsx +++ b/src/components/Watch/CollectVideo/CollectModal.tsx @@ -178,42 +178,41 @@ const CollectModal: FC = ({ {collectModule.referralFee} %
) : null} -
- - {isAllowed ? ( - collectModule?.followerOnly && - !video.profile.isFollowedByMe ? ( -
- -
- Only {isMembershipActive ? 'Members' : 'Subscribers'}{' '} - can collect this publication -
-
-
- ) : balanceLoading && !haveEnoughBalance ? ( -
- -
- ) : haveEnoughBalance ? ( - - ) : ( - - ) +
+ {isAllowed ? ( + collectModule?.followerOnly && !video.profile.isFollowedByMe ? ( +
+ +
+ Only {isMembershipActive ? 'Members' : 'Subscribers'}{' '} + can collect this publication +
+
+
+ ) : balanceLoading && !haveEnoughBalance ? ( +
+ +
+ ) : haveEnoughBalance ? ( + ) : ( - - )} + + ) + ) : ( + + )} + {video?.stats.totalAmountOfCollects > 0 ? ( - + ) : null}
) : ( diff --git a/src/components/Watch/CollectVideo/index.tsx b/src/components/Watch/CollectVideo/index.tsx index 46a132962..646f4d05f 100644 --- a/src/components/Watch/CollectVideo/index.tsx +++ b/src/components/Watch/CollectVideo/index.tsx @@ -10,8 +10,9 @@ import { Analytics, TRACK } from '@utils/analytics' import { ERROR_MESSAGE, LENSHUB_PROXY_ADDRESS, + LENSPORT_MARKETPLACE_URL, RELAYER_ENABLED, - SIGN_IN_REQUIRED_MESSAGE + SIGN_IN_REQUIRED_MESSAGE, } from '@utils/constants' import omitKey from '@utils/functions/omitKey' import { utils } from 'ethers' @@ -161,19 +162,11 @@ const CollectVideo: FC = ({ video, variant = 'primary' }) => { if (!video) { return } - var pubId = '' - if (video.__typename === 'Mirror') { - if (!video.mirrorOf) { - return - } - pubId = video.mirrorOf.id - } else { - pubId = video.id - } + const pubId = video.id ?? video.mirrorOf?.id const decimalProfileId = parseInt(pubId.split('-')[0], 16) const decimalPubId = parseInt(pubId.split('-')[1], 16) const marketplacePublicationId = decimalProfileId + '_' + decimalPubId - const marketplaceUrl = 'http://lensport.io/p/' + marketplacePublicationId + const marketplaceUrl = `${LENSPORT_MARKETPLACE_URL}/p/${marketplacePublicationId}` window.open(marketplaceUrl) } diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 04e5d2671..0c279781e 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -108,6 +108,7 @@ export const OPENSEA_MARKETPLACE_URL = IS_MAINNET export const RARIBLE_MARKETPLACE_URL = IS_MAINNET ? 'https://rarible.com' : 'https://testnet.rarible.com' +export const LENSPORT_MARKETPLACE_URL = 'https://lensport.io' // misc export const GIT_DEPLOYED_COMMIT_SHA = From ae7157eb9ff4968c0a130c48b89b71b141f857eb Mon Sep 17 00:00:00 2001 From: ahomentc Date: Fri, 11 Nov 2022 23:38:51 -0800 Subject: [PATCH 4/4] Update index.tsx Remove extra comma --- src/components/Watch/CollectVideo/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Watch/CollectVideo/index.tsx b/src/components/Watch/CollectVideo/index.tsx index 646f4d05f..aff4f68ec 100644 --- a/src/components/Watch/CollectVideo/index.tsx +++ b/src/components/Watch/CollectVideo/index.tsx @@ -12,7 +12,7 @@ import { LENSHUB_PROXY_ADDRESS, LENSPORT_MARKETPLACE_URL, RELAYER_ENABLED, - SIGN_IN_REQUIRED_MESSAGE, + SIGN_IN_REQUIRED_MESSAGE } from '@utils/constants' import omitKey from '@utils/functions/omitKey' import { utils } from 'ethers'