Skip to content

Commit 93451d5

Browse files
authored
Merge pull request #530 from WatchItDev/next
Next
2 parents 9a9ce70 + 0df5d59 commit 93451d5

11 files changed

+214
-29
lines changed

CHANGELOG.md

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
# [2.2.0-beta.25](https://github.com/WatchItDev/watchit-app/compare/v2.2.0-beta.24...v2.2.0-beta.25) (2025-02-06)
2+
3+
4+
### Bug Fixes
5+
6+
* update metadata ([b361028](https://github.com/WatchItDev/watchit-app/commit/b361028b9566581f9b1565d5509dbde1a1babffc))
7+
8+
# [2.2.0-beta.24](https://github.com/WatchItDev/watchit-app/compare/v2.2.0-beta.23...v2.2.0-beta.24) (2025-02-06)
9+
10+
11+
### Bug Fixes
12+
13+
* improve message on expired session ([0db6364](https://github.com/WatchItDev/watchit-app/commit/0db6364185fb16de4afbc2751d1e8f9e396e8ce9))
14+
15+
# [2.2.0-beta.23](https://github.com/WatchItDev/watchit-app/compare/v2.2.0-beta.22...v2.2.0-beta.23) (2025-02-06)
16+
17+
18+
### Bug Fixes
19+
20+
* **finance:** correct MMC amount in transfer message ([e2f47b5](https://github.com/WatchItDev/watchit-app/commit/e2f47b539918c71260cea36bb2cd460380c2abce))
21+
* fullfill padding on attestations ([1920718](https://github.com/WatchItDev/watchit-app/commit/19207189548057eb73843c1669ba06853520bea7))
22+
* mispelling ([9109afa](https://github.com/WatchItDev/watchit-app/commit/9109afa9f24a72351f20d1a1789bac3f0edc1a82))
23+
* **utils:** improve email regex to avoid partial matches ([df33aff](https://github.com/WatchItDev/watchit-app/commit/df33aff15b4729f7eca71a924b45d26909701ee9))
24+
25+
26+
### Features
27+
28+
* add trimming utility and integrate in publication view ([7e37fbc](https://github.com/WatchItDev/watchit-app/commit/7e37fbc583d1327d81e392e4cffb8ae7083875e5))
29+
130
# [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)
231

332

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.22",
5+
"version": "2.2.0-beta.25",
66
"description": "Open videos everywhere",
77
"email": "[email protected]",
88
"private": true,

src/components/avatar/avatar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface AvatarProfileProps {
1313

1414
const AvatarProfile: FC<AvatarProfileProps> = ({ src, alt, sx, ...other }) => {
1515
//Check if src is a valid URL starting with http or https; if not, use the dicebear API to generate a random avatar
16-
const imageSrc = src.startsWith('http') || src.startsWith('https') ? src : dicebear(src);
16+
const imageSrc = src.startsWith('http') || src.startsWith('blob') || src.startsWith('https') ? src : dicebear(src);
1717

1818
// Default styles for the Avatar component
1919
sx = {

src/hooks/use-account-session.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { setAuthLoading, setSession, setBalance } from '@redux/auth';
99
import { useSession, useLogout } from '@lens-protocol/react-web';
1010

1111
// NOTIFICATIONS IMPORTS
12-
import { ERRORS } from '@notifications/errors';
13-
import { notifyError } from '@notifications/internal-notifications';
12+
import { notifyWarning } from '@notifications/internal-notifications';
1413

1514
// WEB3AUTH IMPORTS
1615
import { useWeb3Auth } from '@src/hooks/use-web3-auth';
1716
import { useWeb3Session } from '@src/hooks/use-web3-session';
17+
import {WARNING} from "@notifications/warnings.ts";
1818

1919
// ----------------------------------------------------------------------
2020

@@ -51,7 +51,7 @@ export const useAccountSession = (): UseAccountSessionHook => {
5151
dispatch(setBalance({ balance: 0 }));
5252
dispatch(setSession({ session: { ...data, authenticated: false } }));
5353
dispatch(setAuthLoading({ isSessionLoading: false }));
54-
if (!silent) notifyError(ERRORS.BUNDLER_UNAVAILABLE);
54+
if (!silent) notifyWarning(WARNING.BUNDLER_UNAVAILABLE);
5555
}, [web3Auth.status]);
5656

5757
// Automatic checks on mount + interval

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ 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 {trimPublicationContentExtraText} from "@src/utils/text-transform.ts";
3637
import { useIsPolicyAuthorized } from '@src/hooks/use-is-policy-authorized.ts';
3738
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
3839

@@ -277,7 +278,7 @@ export default function PublicationDetailsView({ id }: Props) {
277278
opacity: 0.8,
278279
}}
279280
>
280-
<Markdown children={data?.metadata?.content} />
281+
<Markdown children={trimPublicationContentExtraText(data?.metadata?.content)} />
281282
</Box>
282283
{showButton && (
283284
<Button variant="outlined" onClick={toggleDescription} sx={{ mt: 2 }}>

src/sections/user/profile-header.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import ProfileJoin from "@src/sections/user/profile-join.tsx";
3131
import ProfileUserInfo from "@src/sections/user/profile-user-info.tsx";
3232
import ProfileWrapper from './profile-wrapper';
3333
import ProfileToolbar from "@src/sections/user/profile-toolbar.tsx";
34-
import ProfileTransfer from "@src/sections/user/profile-transfer.tsx";
3534

3635
// ----------------------------------------------------------------------
3736
export interface ProfileHeaderProps {
@@ -127,11 +126,7 @@ const ProfileHeader = ({
127126
{profile?.id !== sessionData?.profile?.id && (
128127
<FollowUnfollowButton profileId={profile?.id} />
129128
)}
130-
{
131-
sessionData?.authenticated && profile?.id !== sessionData?.profile?.id && (
132-
<ProfileTransfer profile={profile} />
133-
)
134-
}
129+
135130
</Stack>
136131
</Stack>
137132
</ProfileWrapper>

src/sections/user/profile-toolbar.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {FC} from "react";
77
import {Profile} from "@lens-protocol/api-bindings";
88
import {useTheme} from "@mui/material/styles";
99
import {useSelector} from "react-redux";
10+
import ProfileTransfer from "@src/sections/user/profile-transfer.tsx";
1011

1112
interface ProfileToolbarProps {
1213
profile: Profile;
@@ -60,6 +61,14 @@ const ProfileToolbar: FC<ProfileToolbarProps> = ({profile, profileImage}) => {
6061
{sessionData?.profile && profile?.id === sessionData?.profile?.id && (
6162
<ProfileUpdateButton />
6263
)}
64+
65+
{
66+
sessionData?.authenticated && profile?.id !== sessionData?.profile?.id && (
67+
<ProfileTransfer profile={profile} />
68+
)
69+
}
70+
71+
6372
</Stack>
6473
</Stack>
6574
)
+58-15
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
1-
import {Profile} from "@lens-protocol/api-bindings";
2-
import {FC} from "react";
3-
import FinanceQuickTransferModal from "@src/sections/finance/components/finance-quick-transfer-modal.tsx";
4-
import LoadingButton from "@mui/lab/LoadingButton";
5-
import {useBoolean} from "@src/hooks/use-boolean.ts";
1+
import { Profile } from '@lens-protocol/api-bindings';
2+
import { FC, useCallback, useRef, useState } from 'react';
3+
import FinanceQuickTransferModal from '@src/sections/finance/components/finance-quick-transfer-modal.tsx';
4+
import LoadingButton from '@mui/lab/LoadingButton';
5+
import { useBoolean } from '@src/hooks/use-boolean.ts';
6+
import Iconify from '@src/components/iconify';
7+
import Typography from '@mui/material/Typography';
8+
import Popover from '@mui/material/Popover';
69

710
interface ProfileTransferProps {
811
profile: Profile;
912
}
1013

11-
const ProfileTransfer: FC<ProfileTransferProps> = ({profile}) => {
14+
const ProfileTransfer: FC<ProfileTransferProps> = ({ profile }) => {
15+
const [openTooltipSend, setOpenTooltipSend] = useState(false);
16+
const navRefSend = useRef(null);
1217
const confirm = useBoolean();
1318

1419
const handleOpen = () => {
1520
confirm.onTrue();
16-
}
21+
};
1722

1823
const handleTransferFinish = () => {
1924
confirm.onFalse();
20-
}
25+
};
26+
27+
const handleOpenSend = useCallback(() => {
28+
setOpenTooltipSend(true);
29+
}, []);
30+
31+
const handleCloseSend = useCallback(() => {
32+
setOpenTooltipSend(false);
33+
}, []);
2134

2235
return (
2336
<>
24-
<LoadingButton sx={{
25-
minWidth: { xs: 90, md: 120 },
26-
backgroundColor: '#24262A',
27-
}} variant={'outlined'} onClick={handleOpen}>
28-
Send
37+
<LoadingButton
38+
sx={{
39+
backgroundColor: 'transparent',
40+
minWidth: '44px',
41+
}}
42+
ref={navRefSend}
43+
variant={'outlined'}
44+
onClick={handleOpen}
45+
onMouseEnter={handleOpenSend}
46+
onMouseLeave={handleCloseSend}
47+
>
48+
<Iconify icon="streamline:arrow-transfer-diagonal-3" color="#fff" />
2949
</LoadingButton>
3050

3151
<FinanceQuickTransferModal
@@ -37,8 +57,31 @@ const ProfileTransfer: FC<ProfileTransferProps> = ({profile}) => {
3757
onFinish={handleTransferFinish}
3858
contactInfo={profile}
3959
/>
60+
61+
<Popover
62+
open={openTooltipSend}
63+
anchorEl={navRefSend.current}
64+
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
65+
transformOrigin={{ vertical: 'bottom', horizontal: 'center' }}
66+
slotProps={{
67+
paper: {
68+
onMouseEnter: handleOpenSend,
69+
onMouseLeave: handleCloseSend,
70+
sx: {
71+
mt: 6,
72+
backgroundColor: 'rgba(0,0,0,0.6)',
73+
padding: '8px 20px',
74+
},
75+
},
76+
}}
77+
sx={{
78+
pointerEvents: 'none',
79+
}}
80+
>
81+
<Typography>Send</Typography>
82+
</Popover>
4083
</>
41-
)
42-
}
84+
);
85+
};
4386

4487
export default ProfileTransfer;

src/utils/notifications/errors.ts

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44
export enum ERRORS {
55
NOT_LOGGED_IN = 'NOT_LOGGED_IN',
6-
BUNDLER_UNAVAILABLE = 'BUNDLER_UNAVAILABLE',
76
UNKNOWN_ERROR = 'UNKNOWN_ERROR',
87
METAMASK_CONNECTING_ERROR = 'METAMASK_CONNECTING_ERROR',
98
WITHDRAW_FAILED_ERROR = 'WITHDRAW_FAILED_ERROR',
@@ -98,7 +97,6 @@ export const ERROR_MESSAGES: Record<ERRORS, string> = {
9897

9998
// Withdraw error
10099
[ERRORS.FIRST_LOGIN_ERROR]: 'You must login first to withdraw funds.',
101-
[ERRORS.BUNDLER_UNAVAILABLE]: 'Your session is expired. Please re-login to continue.',
102100

103101
// Deposit error
104102
[ERRORS.DEPOSIT_FAILED_ERROR]: 'Please login to deposit funds.',

src/utils/notifications/warnings.ts

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum WARNING {
77
INVALID_DEPOSIT_AMOUNT = 'INVALID_DEPOSIT_AMOUNT',
88
INVALID_WITHDRAW_AMOUNT = 'INVALID_WITHDRAW_AMOUNT',
99
INVALID_WALLET_ADDRESS = 'INVALID_WALLET_ADDRESS',
10+
BUNDLER_UNAVAILABLE = 'BUNDLER_UNAVAILABLE',
1011
}
1112

1213
/**
@@ -18,4 +19,5 @@ export const WARNING_MESSAGES: Record<WARNING, string> = {
1819
[WARNING.INVALID_DEPOSIT_AMOUNT]: 'Invalid deposit amount.',
1920
[WARNING.INVALID_WITHDRAW_AMOUNT]: 'Invalid withdraw amount.',
2021
[WARNING.INVALID_WALLET_ADDRESS]: 'Invalid wallet address.',
22+
[WARNING.BUNDLER_UNAVAILABLE]: 'Session expired. Please login again.',
2123
};

src/utils/text-transform.ts

+108
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,111 @@ export const pascalToUpperSnake = (str: string): string => {
99
.toUpperCase() // Converts everything to uppercase
1010
.replace(/^_/, ''); // Removes the initial underscore if it exists
1111
};
12+
13+
14+
/**
15+
* An array of strings containing various special character patterns and names.
16+
* The strings in this array include names or identifiers preceded by
17+
* special characters such as dashes, question marks, or periods.
18+
* Some entries also contain only special characters or brace-like structures.
19+
*/
20+
const specialChars = [
21+
'—Huggo',
22+
'?—Nick Riganas',
23+
'.—Rhino',
24+
'—Eric Johnson',
25+
'—Jwelch5742',
26+
'—yusufpiskin',
27+
'—Maths Jesperson',
28+
'—Mark Logan',
29+
'—Snow Leopard',
30+
'—Claudio Carvalho, Rio de Janeiro, Brazil',
31+
'—Johnny-the-Film-Sentinel-2187',
32+
'—grantss',
33+
'—Ed Stephan',
34+
'—filmfactsman',
35+
'—Col Needham',
36+
'—Tony Fontana',
37+
'—garykmcd',
38+
'—',
39+
'?—',
40+
'.—',
41+
'{}',
42+
];
43+
44+
45+
/**
46+
* A regular expression pattern used for matching and validating email addresses.
47+
*
48+
* This pattern supports common email formats, where:
49+
* - The local part can contain alphanumeric characters, dots, underscores,
50+
* percent signs, plus signs, and hyphens.
51+
* - The domain part is structured as one or more labels separated by dots,
52+
* with each label containing alphanumeric characters or hyphens.
53+
* - The top-level domain must be at least two characters long and consist
54+
* only of alphabetic characters.
55+
*
56+
* Flags:
57+
* - The "g" flag enables global matching, allowing multiple occurrences
58+
* of email addresses to be matched in a single string.
59+
*/
60+
const emailRegex = /\b[a-zA-Z0-9][a-zA-Z0-9._%+-]*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}\b/g;
61+
62+
63+
/**
64+
* Removes special characters from the given text string and returns the cleaned string.
65+
*
66+
* @param {string} text - The input string from which special characters will be removed.
67+
* @return {string} - The resulting string after special characters are removed.
68+
*/
69+
function removeSpecialChars(text: string): string {
70+
// Loop through the special characters and replace them with spaces
71+
for (const char of specialChars) {
72+
text = text.replace(char, '').trim();
73+
}
74+
return text;
75+
}
76+
77+
/**
78+
* Detects whether the given text contains a valid email address pattern.
79+
*
80+
* @param {string} text - The string to be checked for an email address.
81+
* @return {boolean} Returns `true` if the text contains a valid email address, otherwise `false`.
82+
*/
83+
function detectEmail(text: string): boolean {
84+
return emailRegex.test(text);
85+
}
86+
87+
/**
88+
* Removes an email address from the provided text string, if present.
89+
*
90+
* @param {string} text - The input string potentially containing an email address.
91+
* @return {string} The modified string with the email address removed and trimmed of extra spaces.
92+
*/
93+
function removeEmail(text: string): string {
94+
return text.replace(emailRegex, '').trim();
95+
}
96+
97+
/**
98+
* Processes and trims extra content from a publication text, including special characters,
99+
* email addresses, and patterns at the end of the text.
100+
*
101+
* @param {string} text - The input string representing the publication content to be processed.
102+
* @returns {string} The processed and cleaned text after applying trimming rules.
103+
*/
104+
export const trimPublicationContentExtraText = (text: string): string => {
105+
const hasEmail = detectEmail(text);
106+
107+
if (hasEmail) {
108+
text = removeEmail(text);
109+
}
110+
111+
let cleanedText = removeSpecialChars(text);
112+
113+
// Verify if the last character is a period, if not, add one
114+
if (!cleanedText.endsWith('.')) {
115+
cleanedText += '.';
116+
}
117+
118+
return `${cleanedText}`;
119+
};

0 commit comments

Comments
 (0)