Skip to content

Commit 7b81b54

Browse files
authored
Merge pull request #524 from WatchItDev/next
Next
2 parents 7ec3315 + c5a2329 commit 7b81b54

9 files changed

+138
-79
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# [2.2.0-beta.22](https://github.com/WatchItDev/watchit-app/compare/v2.2.0-beta.21...v2.2.0-beta.22) (2025-02-02)
2+
3+
4+
### Bug Fixes
5+
6+
* search and select profile on transfer ([37abe06](https://github.com/WatchItDev/watchit-app/commit/37abe068c3364875f7e3d46ca54eed61d6db57db))
7+
* transfer modal, send button disabled ([df1aa7c](https://github.com/WatchItDev/watchit-app/commit/df1aa7c6b1e0aaae57a9324e7d944fbf22e2bf19))
8+
9+
10+
### Features
11+
12+
* added alert on profile to notify when a user has content and the subscription policy is not set, also added the condition to hide the join button on movie details ([111e8ec](https://github.com/WatchItDev/watchit-app/commit/111e8ecd468927500c689800323dc3283063ca2f))
13+
114
# [2.2.0-beta.21](https://github.com/WatchItDev/watchit-app/compare/v2.2.0-beta.20...v2.2.0-beta.21) (2025-01-30)
215

316

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "watchit",
33
"author": "Watchit",
44
"type": "module",
5-
"version": "2.2.0-beta.21",
5+
"version": "2.2.0-beta.22",
66
"description": "Open videos everywhere",
77
"email": "[email protected]",
88
"private": true,

src/components/subscribe-to-unlock-card.tsx

+26-19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useGetPolicyTerms } from '@src/hooks/use-get-policy-terms.ts';
55
import { Address } from 'viem';
66
import LoadingButton from '@mui/lab/LoadingButton';
77
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
8+
import { useIsPolicyAuthorized } from '@src/hooks/use-is-policy-authorized.ts';
89

910
interface Props {
1011
post: any;
@@ -18,10 +19,12 @@ export const SubscribeToUnlockCard = ({
1819
loadingSubscribe,
1920
post,
2021
}: Props) => {
22+
const ownerAddress = post?.by?.ownedBy?.address as Address
2123
const { terms } = useGetPolicyTerms(
2224
GLOBAL_CONSTANTS.SUBSCRIPTION_POLICY_ADDRESS as Address,
23-
post?.by?.ownedBy?.address as Address
25+
ownerAddress
2426
);
27+
const { isAuthorized } = useIsPolicyAuthorized(GLOBAL_CONSTANTS.SUBSCRIPTION_POLICY_ADDRESS, ownerAddress);
2528
const durationDays = 30; // a month
2629
const totalCostWei = terms?.amount ? terms?.amount * BigInt(durationDays) : 0; // Calculate total cost in Wei: DAILY_COST_WEI * durationDays
2730
const totalCostMMC = ethers.formatUnits(totalCostWei, 18); // Converts Wei to MMC
@@ -50,24 +53,28 @@ export const SubscribeToUnlockCard = ({
5053
This content is exclusively for members. Become part of our growing community to access
5154
behind-the-scenes content, exclusive posts, and much more!
5255
</Typography>
53-
<LoadingButton
54-
variant="contained"
55-
color="primary"
56-
sx={{ width: '100%', py: 1.5 }}
57-
onClick={onSubscribe}
58-
loading={loadingSubscribe}
59-
// disabled={subscribeDisabled}
60-
>
61-
<IconPlayerPlay size={20} style={{ marginRight: 5 }} />
62-
Join
63-
</LoadingButton>
64-
<Box sx={{ mt: 3, borderRadius: 1 }}>
65-
<Typography variant="body2" color="textSecondary">
66-
Join now for just <strong>{totalCostMMC} MMC/month</strong> and access to{' '}
67-
<strong>{post?.by?.stats?.posts}</strong> exclusive posts from{' '}
68-
<strong>{post?.by?.metadata?.displayName ?? post?.handle?.localName}!</strong>
69-
</Typography>
70-
</Box>
56+
{isAuthorized && (
57+
<>
58+
<LoadingButton
59+
variant="contained"
60+
color="primary"
61+
sx={{ width: '100%', py: 1.5 }}
62+
onClick={onSubscribe}
63+
loading={loadingSubscribe}
64+
// disabled={subscribeDisabled}
65+
>
66+
<IconPlayerPlay size={20} style={{ marginRight: 5 }} />
67+
Join
68+
</LoadingButton>
69+
<Box sx={{ mt: 3, borderRadius: 1 }}>
70+
<Typography variant="body2" color="textSecondary">
71+
Join now for just <strong>{totalCostMMC} MMC/month</strong> and access to{' '}
72+
<strong>{post?.by?.stats?.posts}</strong> exclusive posts from{' '}
73+
<strong>{post?.by?.metadata?.displayName ?? post?.handle?.localName}!</strong>
74+
</Typography>
75+
</Box>
76+
</>
77+
)}
7178
</CardContent>
7279
</Card>
7380
);

src/sections/finance/components/finance-display-profile-info.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const FinanceDisplayProfileInfo: FC<FinanceDisplayNameProps> = ({initialList, ca
3838
{
3939
mode === 'profile' ?
4040
(<Box component="span" sx={{ flexGrow: 1, typography: 'subtitle1' }}>
41-
{selectedProfile?.metadata?.displayName ?? 'No profile selected'}
41+
{selectedProfile?.metadata?.displayName ?? selectedProfile?.handle?.localName ?? 'No profile selected'}
4242
</Box>) : null
4343
}
4444
{

src/sections/finance/components/finance-quick-transfer-modal.tsx

+46-31
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,18 @@ function FinanceQuickTransferModal({
5959
const { sendNotification } = useNotifications();
6060
const [message, setMessage] = useState('');
6161

62-
// For transfer button is clicked in some profile
62+
// For the transfer button when using user input
6363
const MAX_AMOUNT = useSelector((state: any) => state.auth.balance);
6464
const [value, setValue] = useState(0);
6565
const [canContinue, setCanContinue] = useState(true);
6666

67-
// Check if we have a valid profile or not
67+
// Check if we have a valid profile
6868
const hasProfile = !!contactInfo;
6969

7070
// Check if the passed address matches the profile's address
7171
const isSame =
72-
hasProfile && contactInfo?.ownedBy?.address?.toLowerCase() === address?.toLowerCase();
72+
hasProfile &&
73+
contactInfo?.ownedBy?.address?.toLowerCase() === address?.toLowerCase();
7374

7475
// If no valid profile, show "Destination wallet", else use profile’s displayName
7576
const displayName = hasProfile
@@ -107,9 +108,14 @@ function FinanceQuickTransferModal({
107108
}
108109
}
109110

111+
// Define the transfer amount: if a positive 'amount' is passed, use it; otherwise, use the entered value
112+
const transferAmount = amount > 0 ? amount : value;
113+
// Validation: if 'amount' is passed, assume it's valid; otherwise, ensure that the value is greater than 0 and input validation (canContinue) passes.
114+
const isTransferValid = transferAmount > 0 && (amount > 0 || canContinue);
115+
110116
const handleConfirmTransfer = async () => {
111117
try {
112-
await transfer({ amount: amount > 0 ? amount: value, recipient: address ?? '' });
118+
await transfer({ amount: transferAmount, recipient: address ?? '' });
113119

114120
onFinish();
115121

@@ -120,57 +126,65 @@ function FinanceQuickTransferModal({
120126
'TRANSFER',
121127
{
122128
id: isSame ? (contactInfo?.id ?? '') : (address ?? ''),
123-
displayName: isSame ? (contactInfo?.metadata?.displayName ?? 'No name') : 'External wallet',
129+
displayName: isSame
130+
? (contactInfo?.metadata?.displayName ?? 'No name')
131+
: 'External wallet',
124132
avatar: (contactInfo?.metadata?.picture as any)?.optimized?.uri ?? '',
125133
},
126134
{
127-
rawDescription: `${sessionData?.profile?.metadata?.displayName ?? address} sent you ${amount} MMC`,
135+
rawDescription: `${sessionData?.profile?.metadata?.displayName ?? address} sent you ${transferAmount} MMC`,
128136
message,
129137
}
130138
);
131139

132-
// Store transaction in supabase
140+
// Store transaction in Supabase
133141
await storeTransactionInSupabase(contactInfo?.id ?? address, senderId, {
134142
address: contactInfo?.ownedBy?.address ?? address,
135-
amount: amount > 0 ? amount : value,
143+
amount: transferAmount,
136144
message,
137145
...notificationPayload,
138146
});
139147

140-
// Send notification to lens profile or address
148+
// Send notification to the Lens profile or address
141149
await sendNotification(
142150
contactInfo?.id ?? address ?? '',
143151
sessionData?.profile?.id,
144152
notificationPayload
145153
);
146154

147155
notifySuccess(SUCCESS.TRANSFER_CREATED_SUCCESSFULLY, {
148-
destination: isSame ? contactInfo?.metadata?.displayName : truncateAddress(address ?? ''),
156+
destination: isSame
157+
? contactInfo?.metadata?.displayName ?? contactInfo?.handle?.localName
158+
: truncateAddress(address ?? ''),
149159
});
150160
} catch (err: any) {
151161
notifyError(ERRORS.TRANSFER_FAILED_ERROR);
152162
}
153163
};
154164

155-
const handleChangeInput = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
156-
const value = Number(event.target.value);
157-
handleAmountConstraints({value, MAX_AMOUNT, MAX_POOL, setAmount: setValue, setCanContinue});
158-
}, [MAX_AMOUNT]);
159-
165+
const handleChangeInput = useCallback(
166+
(event: React.ChangeEvent<HTMLInputElement>) => {
167+
const value = Number(event.target.value);
168+
handleAmountConstraints({ value, MAX_AMOUNT, MAX_POOL, setAmount: setValue, setCanContinue });
169+
},
170+
[MAX_AMOUNT]
171+
);
160172

161173
const handleBlur = useCallback(() => {
162-
handleAmountConstraints({value, MAX_AMOUNT, MAX_POOL, setAmount: setValue, setCanContinue});
174+
handleAmountConstraints({ value, MAX_AMOUNT, MAX_POOL, setAmount: setValue, setCanContinue });
163175
}, [value, MAX_AMOUNT]);
164176

165177
const RainbowEffect = transferLoading ? NeonPaper : Box;
166178

167179
return (
168180
<Dialog open={open} fullWidth maxWidth="xs" onClose={onClose}>
169-
<DialogTitle sx={{
170-
borderBottom: `dashed 1px ${theme.palette.divider}`,
171-
padding: '16px 24px',
172-
marginBottom: '8px'
173-
}}>
181+
<DialogTitle
182+
sx={{
183+
borderBottom: `dashed 1px ${theme.palette.divider}`,
184+
padding: '16px 24px',
185+
marginBottom: '8px',
186+
}}
187+
>
174188
Send to
175189
</DialogTitle>
176190
<Stack direction="column" spacing={3} sx={{ px: 3 }}>
@@ -190,19 +204,20 @@ function FinanceQuickTransferModal({
190204
</Stack>
191205

192206
<Stack direction="column" spacing={0} sx={{ py: 2, flexGrow: 1 }}>
193-
{amount > 0 ? (
194-
207+
{amount > 0 ? (
195208
<ListItemText
196209
primary="Amount:"
197210
secondary={`${amount} MMC`}
198211
secondaryTypographyProps={{ component: 'span', mt: 0.5 }}
199212
/>
200-
) : <InputAmount
201-
max={MAX_POOL}
202-
amount={value}
203-
onBlur={handleBlur}
204-
onChange={handleChangeInput}
205-
/>}
213+
) : (
214+
<InputAmount
215+
max={MAX_POOL}
216+
amount={value}
217+
onBlur={handleBlur}
218+
onChange={handleChangeInput}
219+
/>
220+
)}
206221
</Stack>
207222
</Stack>
208223

@@ -219,7 +234,7 @@ function FinanceQuickTransferModal({
219234
sx={{
220235
borderTop: `dashed 1px ${theme.palette.divider}`,
221236
padding: '16px 24px',
222-
marginTop: '24px'
237+
marginTop: '24px',
223238
}}
224239
>
225240
<Button onClick={onClose}>Cancel</Button>
@@ -236,7 +251,7 @@ function FinanceQuickTransferModal({
236251
variant="contained"
237252
sx={{ backgroundColor: '#fff' }}
238253
onClick={handleConfirmTransfer}
239-
disabled={transferLoading || !canContinue || value <= 0}
254+
disabled={transferLoading || !isTransferValid}
240255
loading={transferLoading}
241256
>
242257
Confirm

src/sections/finance/components/finance-quick-transfer.tsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export default function FinanceQuickTransfer({
103103

104104
// 3) Move the carousel right now
105105
carousel.setCurrentIndex(finalIndex);
106+
setCurrentIndex(finalIndex);
106107

107108
// 4) Update the wallet address & Redux
108109
setWalletAddress(profile.ownedBy?.address ?? '');
@@ -254,9 +255,6 @@ export default function FinanceQuickTransfer({
254255
}
255256
}, [showRainbow, currentIndex, carousel]);
256257

257-
// We pick the contactInfo to pass to the modal. If currentIndex is -1, there's no matched profile
258-
const contactInfoToPass = currentIndex === -1 ? undefined : getContactInfo;
259-
260258
// Render the carousel of profiles
261259
const renderCarousel = (
262260
<Box sx={{ position: 'relative', mb: 3 }}>
@@ -374,7 +372,6 @@ export default function FinanceQuickTransfer({
374372

375373
const Wrapper = showRainbow ? NeonPaper : Box;
376374

377-
console.log(list);
378375
return (
379376
<>
380377
<Wrapper
@@ -400,9 +397,9 @@ export default function FinanceQuickTransfer({
400397

401398
{/* Content */}
402399
<Stack sx={{ p: 3 }}>
403-
<FinanceDisplayProfileInfo mode={'profile'} initialList={initialList} carousel={carousel} />
400+
<FinanceDisplayProfileInfo mode={'profile'} initialList={list} carousel={carousel} />
404401
{list?.length > 0 ? renderCarousel : <FinanceNoFollowingsQuickTransfer />}
405-
<FinanceDisplayProfileInfo mode={'wallet'} initialList={initialList} carousel={carousel} />
402+
<FinanceDisplayProfileInfo mode={'wallet'} initialList={list} carousel={carousel} />
406403
{renderInput}
407404
</Stack>
408405
</Stack>
@@ -417,7 +414,7 @@ export default function FinanceQuickTransfer({
417414
address={walletAddress}
418415
onClose={confirm.onFalse}
419416
onFinish={handleTransferFinish}
420-
contactInfo={contactInfoToPass} // If currentIndex is -1, this is undefined
417+
contactInfo={getContactInfo}
421418
onChange={handleChangeInput}
422419
/>
423420
</>

src/sections/publication/view/publication-details-view.tsx

+25-20
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import LoadingButton from '@mui/lab/LoadingButton';
3333
import { useDispatch, useSelector } from 'react-redux';
3434
import { openLoginModal } from '@redux/auth';
3535
import { appId, PublicationType, usePublications } from '@lens-protocol/react-web';
36+
import { useIsPolicyAuthorized } from '@src/hooks/use-is-policy-authorized.ts';
37+
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
3638

3739
const MAX_LINES = 5;
3840

@@ -68,6 +70,7 @@ export default function PublicationDetailsView({ id }: Props) {
6870
fetching: accessFetchingLoading,
6971
refetch: refetchAccess,
7072
} = useHasAccess(ownerAddress);
73+
const { isAuthorized } = useIsPolicyAuthorized(GLOBAL_CONSTANTS.SUBSCRIPTION_POLICY_ADDRESS, ownerAddress);
7174

7275
const getMediaUri = (cid: string): string => `${cid}`;
7376

@@ -223,26 +226,28 @@ export default function PublicationDetailsView({ id }: Props) {
223226
}}
224227
/>
225228

226-
<LoadingButton
227-
variant="contained"
228-
sx={{
229-
color: '#1E1F22',
230-
background: '#FFFFFF',
231-
height: '35px',
232-
bottom: 16,
233-
left: 16,
234-
position: 'absolute',
235-
zIndex: 2,
236-
}}
237-
onClick={handleSubscribe}
238-
// disabled={accessLoading || hasAccess || accessFetchingLoading}
239-
loading={accessLoading || accessFetchingLoading}
240-
>
241-
<IconPlayerPlay fontSize="large" size={18} />
242-
<Typography variant="body2" sx={{ lineHeight: 1, fontWeight: '700', ml: 1 }}>
243-
Join
244-
</Typography>
245-
</LoadingButton>
229+
{isAuthorized && (
230+
<LoadingButton
231+
variant="contained"
232+
sx={{
233+
color: '#1E1F22',
234+
background: '#FFFFFF',
235+
height: '35px',
236+
bottom: 16,
237+
left: 16,
238+
position: 'absolute',
239+
zIndex: 2,
240+
}}
241+
onClick={handleSubscribe}
242+
// disabled={accessLoading || hasAccess || accessFetchingLoading}
243+
loading={accessLoading || accessFetchingLoading}
244+
>
245+
<IconPlayerPlay fontSize="large" size={18} />
246+
<Typography variant="body2" sx={{ lineHeight: 1, fontWeight: '700', ml: 1 }}>
247+
Join
248+
</Typography>
249+
</LoadingButton>
250+
)}
246251
</Box>
247252
)}
248253

0 commit comments

Comments
 (0)