Skip to content

Commit ca67f03

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into delete-msg-options-updated
2 parents 9b94899 + 0f94093 commit ca67f03

File tree

9 files changed

+60
-16
lines changed

9 files changed

+60
-16
lines changed

dynamic_assets

ts/components/conversation/message/message-content/quote/QuoteText.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { MessageBody } from '../MessageBody';
1111
import { QuoteProps } from './Quote';
1212
import { tr } from '../../../../../localization/localeTools';
1313
import { MessageDeletedType } from '../../../../../models/messageType';
14+
import { collapseString } from '../../../../../shared/string_utils';
1415

1516
const StyledQuoteText = styled.div<{ $isIncoming: boolean }>`
1617
display: -webkit-box;
@@ -73,12 +74,9 @@ export function getShortenedFilename(fileName: string) {
7374
if (!fileName) {
7475
return '';
7576
}
76-
if (fileName?.length < 20) {
77-
return fileName;
78-
}
7977
const charsAround = 15;
8078

81-
return `${fileName.slice(0, charsAround)}${fileName.slice(-charsAround)}`;
79+
return collapseString(fileName, charsAround, charsAround, true);
8280
}
8381

8482
export const QuoteText = (

ts/components/dialog/user-settings/pages/user-pro/ProNonOriginatingPage.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ function ProInfoBlockDeviceLinked() {
192192
);
193193
}
194194

195-
function ProInfoBlockWebsite({ textElement }: { textElement: ReactNode }) {
195+
function ProInfoBlockWebsite({
196+
textElement,
197+
titleType,
198+
}: {
199+
textElement: ReactNode;
200+
titleType: 'via' | 'onThe';
201+
}) {
196202
const { data } = useProBackendProDetailsLocal();
197203
const storeOrPlatform = useStoreOrPlatformFromProvider(data);
198204

@@ -202,7 +208,7 @@ function ProInfoBlockWebsite({ textElement }: { textElement: ReactNode }) {
202208
textElement={
203209
<ProInfoBlockText>
204210
<strong>
205-
{tr('viaStoreWebsite', {
211+
{tr(titleType === 'via' ? 'viaStoreWebsite' : 'onPlatformWebsite', {
206212
platform: storeOrPlatform,
207213
})}
208214
</strong>
@@ -305,6 +311,7 @@ function ProInfoBlockUpdate() {
305311
}
306312
/>
307313
<ProInfoBlockWebsite
314+
titleType="via"
308315
textElement={
309316
<Localizer
310317
token="viaStoreWebsiteDescription"
@@ -347,6 +354,7 @@ function ProInfoBlockRenew() {
347354
<>
348355
<ProInfoBlockDeviceLinked />
349356
<ProInfoBlockWebsite
357+
titleType="onThe"
350358
textElement={
351359
<Localizer
352360
token="proAccessRenewPlatformStoreWebsite"
@@ -363,6 +371,8 @@ function ProInfoBlockRenew() {
363371

364372
function ProInfoBlockCancel() {
365373
const { data } = useProBackendProDetailsLocal();
374+
const storeOrPlatform = useStoreOrPlatformFromProvider(data);
375+
366376
return (
367377
<ProInfoBlockLayout
368378
titleElement={tr('proCancellation')}
@@ -387,10 +397,11 @@ function ProInfoBlockCancel() {
387397
}
388398
/>
389399
<ProInfoBlockWebsite
400+
titleType="onThe"
390401
textElement={
391402
<Localizer
392403
token="cancelProPlatformStore"
393-
platform_store={data.providerConstants.platform}
404+
platform_store={storeOrPlatform}
394405
platform_account={data.providerConstants.platform_account}
395406
/>
396407
}
@@ -472,6 +483,7 @@ function ProInfoBlockRefundIOS() {
472483
}
473484
/>
474485
<ProInfoBlockWebsite
486+
titleType="onThe"
475487
textElement={
476488
<Localizer
477489
token="requestRefundPlatformWebsite"

ts/components/dialog/user-settings/pages/user-pro/ProSettingsPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,6 @@ function ProSettings({ state }: SectionProps) {
492492
subText = { token: 'errorLoadingProAccess' };
493493
} else if (isLoading) {
494494
subText = { token: 'proAccessLoadingEllipsis' };
495-
} else if (data.isProcessingRefund) {
496-
subText = { token: 'processingRefundRequest', platform: data.providerConstants.platform };
497495
} else if (data.inGracePeriod) {
498496
subText = { token: 'proRenewalUnsuccessful' };
499497
} else if (data.autoRenew) {
@@ -509,6 +507,10 @@ function ProSettings({ state }: SectionProps) {
509507
{data.isProcessingRefund ? (
510508
<PanelIconButton
511509
text={{ token: 'proRequestedRefund' }}
510+
subText={{
511+
token: 'processingRefundRequest',
512+
platform: data.providerConstants.platform,
513+
}}
512514
dataTestId="update-access-settings-button"
513515
onClick={handleUpdateAccessClick}
514516
iconElement={<PanelIconLucideIcon unicode={LUCIDE_ICONS_UNICODE.CIRCLE_ALERT} />}

ts/components/icon/MailWithUnreadIcon.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { SessionDataTestId } from 'react';
12
import styled from 'styled-components';
23
import type { SessionIconSize } from './Icons';
34
import { IconSizeToPxStr } from './SessionIcon';
@@ -9,8 +10,10 @@ const MailWithUnreadContainer = styled.div`
910
export function MailWithUnreadIcon({
1011
iconSize,
1112
style,
13+
dataTestId,
1214
}: {
1315
iconSize: SessionIconSize;
16+
dataTestId?: SessionDataTestId;
1417
style?: React.CSSProperties;
1518
}) {
1619
const sizePx = IconSizeToPxStr[iconSize];
@@ -22,6 +25,7 @@ export function MailWithUnreadIcon({
2225
height={sizePx}
2326
fill="none"
2427
viewBox="0 0 17 17"
28+
data-testid={dataTestId}
2529
>
2630
<path
2731
fill="currentColor"

ts/components/leftpane/conversation-list-item/HeaderItem.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const NotificationSettingIcon = () => {
3838
iconColor="currentColor"
3939
iconSize="small"
4040
style={{ flexShrink: 0 }}
41+
dataTestId="conversation-item-muted"
4142
/>
4243
);
4344
case 'mentions_only':
@@ -46,6 +47,7 @@ const NotificationSettingIcon = () => {
4647
iconType="bell"
4748
iconColor="currentColor"
4849
iconSize="small"
50+
dataTestId="conversation-item-mentions-only"
4951
style={{ flexShrink: 0 }}
5052
/>
5153
);
@@ -72,6 +74,7 @@ const PinIcon = () => {
7274
iconColor="currentColor"
7375
iconSize="small"
7476
style={{ flexShrink: 0 }}
77+
dataTestId="conversation-item-pinned"
7578
/>
7679
) : null;
7780
};
@@ -152,6 +155,7 @@ const AtSymbol = ({ conversationId }: WithConvoId) => {
152155
title="Open to latest mention"
153156
// eslint-disable-next-line @typescript-eslint/no-misused-promises
154157
onMouseDown={async e => openConvoToLastMention(e, conversationId)}
158+
data-testid="conversation-item-mentioned-us"
155159
>
156160
@
157161
</MentionAtSymbol>
@@ -185,14 +189,24 @@ const UnreadCount = ({ conversationId }: WithConvoId) => {
185189
: unreadMsgCount || ' ';
186190

187191
if (forcedUnread) {
188-
return <MailWithUnreadIcon iconSize="small" style={{ maxHeight: '100%' }} />;
192+
return (
193+
<MailWithUnreadIcon
194+
iconSize="small"
195+
style={{ maxHeight: '100%' }}
196+
dataTestId="conversation-item-forced-unread"
197+
/>
198+
);
189199
}
190200

191201
if (unreadMsgCount <= 0) {
192202
return null;
193203
}
194204

195-
return <StyledUnreadCount>{unreadWithOverflow}</StyledUnreadCount>;
205+
return (
206+
<StyledUnreadCount data-testid="conversation-item-unread-count">
207+
{unreadWithOverflow}
208+
</StyledUnreadCount>
209+
);
196210
};
197211

198212
export const ConversationListItemHeaderItem = () => {

ts/react.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ declare module 'react' {
230230
| 'name'
231231
| 'count';
232232

233+
type ConversationItemFlagsIds =
234+
| 'conversation-item-muted'
235+
| 'conversation-item-pinned'
236+
| 'conversation-item-mentions-only'
237+
| 'conversation-item-forced-unread'
238+
| 'conversation-item-unread-count'
239+
| 'conversation-item-mentioned-us';
240+
233241
type SessionDataTestId =
234242
| 'group-member-status-text'
235243
| 'loading-spinner'
@@ -283,6 +291,9 @@ declare module 'react' {
283291
// Buttons
284292
| `${Buttons}-button`
285293

294+
// Conversation Item Flags
295+
| ConversationItemFlagsIds
296+
286297
// settings menu item types
287298
| `${MenuItems}-menu-item`
288299
| `${SettingsMenuItems}-settings-menu-item`

ts/shared/string_utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@ export function uniqFromListOfList<T extends string>(list: Array<Array<T>>): Arr
99

1010
/**
1111
* Collapses a string by replacing characters between the leading and trailing characters with a triple ellipsis unicode character (length 1).
12-
* The final length of the string will be the sum of the leading and trailing characters plus 1.
12+
* The final length of the string will be the sum of the leading and trailing characters plus 1 (or 3 if spacesAroundEllipsis is true).
1313
* @param str - The input string to collapse.
1414
* @param leadingChars - The number of characters to keep at the beginning of the string.
1515
* @param trailingChars - The number of characters to keep at the end of the string.
16+
* @param spacesAroundEllipsis - Whether to add spaces around the ellipsis.
1617
* @param separator - The separator to use between the leading and trailing characters.
1718
* @returns The collapsed string.
1819
*/
1920
export const collapseString = (
2021
str: string,
2122
leadingChars = 6,
2223
trailingChars = 4,
24+
spacesAroundEllipsis = false,
2325
separator = '…'
2426
): string => {
25-
if (str.length <= leadingChars + trailingChars + 3) {
27+
if (str.length <= leadingChars + trailingChars + 1 + (spacesAroundEllipsis ? 2 : 0)) {
2628
return str;
2729
}
28-
return `${str.slice(0, leadingChars)}${separator}${str.slice(-trailingChars)}`;
30+
const ellipsis = spacesAroundEllipsis ? ` ${separator} ` : separator;
31+
return `${str.slice(0, leadingChars)}${ellipsis}${str.slice(-trailingChars)}`;
2932
};

0 commit comments

Comments
 (0)