Skip to content

Commit 1777d27

Browse files
morethanwordsclaude
andcommitted
Merge pull request #742 from redjex/unsupported-message-plate
Chat: a message the client cannot show is a plate on its sender's side, as on Android Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 parents e27095e + 337223f commit 1777d27

6 files changed

Lines changed: 104 additions & 4 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {i18n} from '@lib/langPack';
2+
3+
const CLASS_NAME = 'bubble-unsupported';
4+
5+
const ICON_SVG = `<svg class="${CLASS_NAME}-icon" viewBox="0 0 144 144" aria-hidden="true">
6+
<path class="${CLASS_NAME}-icon-bubble" fill-rule="evenodd" d="M72.5,14C104.81,14 131,40.19 131,72.5C131,104.81 104.81,131 72.5,131C60.92,131 50.12,127.63 41.04,121.83L19.43,129.16C17.14,129.94 14.92,127.81 15.59,125.49L22.22,102.42C17,93.67 14,83.43 14,72.5C14,40.19 40.19,14 72.5,14Z"/>
7+
<path class="${CLASS_NAME}-icon-plane" fill-rule="evenodd" transform="translate(33 33) scale(1.0833)" d="M6.232,35.046C22.115,28.147 32.706,23.599 38.006,21.401C53.136,15.126 56.28,14.036 58.329,14C58.78,13.992 59.788,14.104 60.441,14.632C60.992,15.078 61.143,15.68 61.216,16.103C61.289,16.526 61.379,17.489 61.307,18.241C60.487,26.831 56.939,47.675 55.134,57.295C54.371,61.366 52.867,62.731 51.411,62.865C48.247,63.155 45.844,60.78 42.78,58.777C37.985,55.643 35.276,53.692 30.621,50.634C25.242,47.1 28.729,45.157 31.795,41.983C32.597,41.152 46.537,28.51 46.807,27.363C46.841,27.22 46.872,26.685 46.554,26.403C46.235,26.12 45.765,26.217 45.426,26.294C44.945,26.402 37.284,31.451 22.444,41.438C20.27,42.927 18.3,43.652 16.536,43.614C14.591,43.572 10.849,42.518 8.067,41.616C4.655,40.51 2.448,39.938 2.684,38.06C2.807,37.082 3.99,36.077 6.232,35.046Z"/>
8+
</svg>`;
9+
10+
export default function wrapUnsupportedMessagePlate(container: HTMLElement) {
11+
container.classList.add(`${CLASS_NAME}-wrapper`);
12+
container.insertAdjacentHTML('beforeend', ICON_SVG);
13+
14+
const text = document.createElement('div');
15+
text.classList.add(`${CLASS_NAME}-text`);
16+
17+
const title = i18n('UnsupportedMessageTitle');
18+
title.classList.add(`${CLASS_NAME}-title`);
19+
20+
const subtitle = i18n('UnsupportedMessageMessage');
21+
subtitle.classList.add(`${CLASS_NAME}-subtitle`);
22+
23+
text.append(title, subtitle);
24+
25+
container.append(text);
26+
}

‎src/components/chat/bubbles.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ import {modifyAckedPromise} from '@helpers/modifyAckedResult';
148148
import callbackify from '@helpers/callbackify';
149149
import {avatarNew, findUpAvatar} from '@components/avatarNew';
150150
import Icon from '@components/icon';
151+
import wrapUnsupportedMessagePlate from '@components/chat/bubbleParts/unsupportedMessagePlate';
151152
import SendingStatusIcon, {SendingStatusIconState, setSendingStatusIconState} from '@components/sendingStatusIcon';
152153
import wrapCallBubble from '@components/wrappers/callBubble';
153154
import {FullMid, makeFullMid, splitFullMid} from '@appManagers/utils/messages/fullMid';
@@ -347,18 +348,21 @@ if(IS_GROUP_CALL_SUPPORTED) {
347348

348349
const isStoryMentionMessage = (message: Message.message) => !!(message.media as MessageMedia.messageMediaStory)?.pFlags?.via_mention;
349350
const isSelfDestructingMediaMessage = (message: Message.message) => !!(message.media as MessageMedia.messageMediaPhoto)?.ttl_seconds;
351+
const isUnsupportedMessage = (message: Message.message) => message.media?._ === 'messageMediaUnsupported';
350352

351353
/**
352354
* Whether a message is drawn as a service line, neither incoming nor outgoing: a service message but a call, a
353-
* story mention, self-destructing media that cannot be seen
355+
* story mention, self-destructing media that cannot be seen, a message this client cannot show
354356
*/
355357
function isDrawnAsService(message: Message.message | Message.messageService) {
356358
if(message._ !== 'message') {
357359
const action = (message as Message.messageService).action;
358360
return !action || !SERVICE_AS_REGULAR.has(action._);
359361
}
360362

361-
return isStoryMentionMessage(message) || (isSelfDestructingMediaMessage(message) && !canSeeMessageMedia(message));
363+
return isStoryMentionMessage(message) ||
364+
(isSelfDestructingMediaMessage(message) && !canSeeMessageMedia(message)) ||
365+
isUnsupportedMessage(message);
362366
}
363367

364368
// Service actions whose inline photo (suggested profile photo, or a group/channel
@@ -9088,6 +9092,7 @@ export default class ChatBubbles {
90889092

90899093
const isStoryMention = isMessage && isStoryMentionMessage(message);
90909094
const isSelfDestructingMedia = isMessage && isSelfDestructingMediaMessage(message);
9095+
const isUnsupported = isMessage && isUnsupportedMessage(message);
90919096
let returnService: boolean;
90929097

90939098
if(
@@ -9703,6 +9708,9 @@ export default class ChatBubbles {
97039708

97049709
s.append(avatarContainer, text, button);
97059710
}
9711+
} else if(isUnsupported) {
9712+
bubble.classList.add('is-unsupported', this.chat.isOutMessage(message) ? 'is-unsupported-out' : 'is-unsupported-in');
9713+
wrapUnsupportedMessagePlate(s);
97069714
} else if(isSelfDestructingMedia) {
97079715
const promise = wrapMessageForReply({
97089716
message,

‎src/components/wrappers/messageForReply.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export default async function wrapMessageForReply<T extends WrapMessageForReplyO
265265
break;
266266
}
267267

268-
addPart(UNSUPPORTED_LANG_PACK_KEY);
268+
addPart('UnsupportedMessageTitle');
269269
break;
270270
}
271271

‎src/lang.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ const lang = {
493493
'Message.Context.Selection.SendNow': 'Send selected now',
494494
'Message.Unsupported.Desktop': '__This message is currently not supported on Telegram Web. Try [getdesktop.telegram.org](https://getdesktop.telegram.org/)__',
495495
'Message.Unsupported.Mobile': '__This message is currently not supported on Telegram Web. Try [telegram.org/dl](https://telegram.org/dl/)__',
496+
'UnsupportedMessageTitle': 'Unsupported Message',
497+
'UnsupportedMessageMessage': 'Update Telegram to view this message',
496498
'RichMessage.Error.TooLong': 'This rich text message is too long (%1$d of %2$d characters).',
497499
'RichMessage.Error.TooManyBlocks': 'This rich text message has too many blocks (%1$d of %2$d).',
498500
'RichMessage.Error.TooDeep': 'This rich text message is nested too deeply (%1$d of %2$d levels).',

‎src/scss/partials/_chat.scss‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,8 @@
14991499

15001500
&.is-chat,
15011501
&.with-message-avatars {
1502-
.is-in .bubble-content-wrapper {
1502+
.is-in .bubble-content-wrapper,
1503+
.bubble.is-unsupported-in .bubble-content-wrapper {
15031504
margin-inline-start: 2.875rem;
15041505
}
15051506
}

‎src/scss/partials/_chatBubble.scss‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,55 @@
25182518
}
25192519
}
25202520

2521+
&-unsupported {
2522+
&-wrapper {
2523+
display: flex !important;
2524+
align-items: center;
2525+
gap: .5rem;
2526+
width: 25rem;
2527+
max-width: 100%;
2528+
padding: .4375rem .6875rem .4375rem .375rem !important;
2529+
border-radius: 1.125rem !important;
2530+
text-align: start;
2531+
}
2532+
2533+
&-icon {
2534+
flex: 0 0 auto;
2535+
width: 3rem;
2536+
height: 3rem;
2537+
2538+
&-bubble {
2539+
fill: rgba(0, 0, 0, .11);
2540+
}
2541+
2542+
&-plane {
2543+
fill: currentColor;
2544+
}
2545+
}
2546+
2547+
&-text {
2548+
flex: 1 1 auto;
2549+
min-width: 0;
2550+
display: flex;
2551+
flex-direction: column;
2552+
gap: .125rem;
2553+
text-align: start;
2554+
}
2555+
2556+
&-title {
2557+
@include text-overflow();
2558+
font-size: var(--font-size-14);
2559+
line-height: var(--line-height-14);
2560+
font-weight: var(--font-weight-bold);
2561+
}
2562+
2563+
&-subtitle {
2564+
font-size: var(--font-size-13);
2565+
line-height: var(--line-height-13);
2566+
opacity: .7;
2567+
}
2568+
}
2569+
25212570
// Generic "media + caption + button" service bubble (e.g. suggested profile
25222571
// photo). Centered round media, modeled on the story-mention bubble above.
25232572
&-service-media {
@@ -3419,6 +3468,20 @@
34193468
padding: 0 2rem;
34203469
}
34213470
}
3471+
3472+
&.is-unsupported {
3473+
.bubble-content-wrapper {
3474+
padding: 0;
3475+
}
3476+
3477+
&-in {
3478+
justify-content: flex-start;
3479+
}
3480+
3481+
&-out {
3482+
justify-content: flex-end;
3483+
}
3484+
}
34223485
}
34233486

34243487
.bubble.service, .bubble.has-fake-service {

0 commit comments

Comments
 (0)