Skip to content

Commit

Permalink
Merge pull request #62 from ulu-telegram/master
Browse files Browse the repository at this point in the history
deploy
  • Loading branch information
ulugmer authored Nov 10, 2023
2 parents 18ac4b6 + 73a1f03 commit 32eed8c
Show file tree
Hide file tree
Showing 31 changed files with 251 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .patch-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17
18
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telegram-t",
"version": "10.0.17",
"version": "10.0.18",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.0.17
10.0.18
9 changes: 7 additions & 2 deletions src/components/common/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import buildAttachment, { prepareAttachmentsToSend } from '../middle/composer/he
import { escapeHtml } from '../middle/composer/helpers/cleanHtml';
import { buildCustomEmojiHtml } from '../middle/composer/helpers/customEmoji';
import { isSelectionInsideInput } from '../middle/composer/helpers/selection';
import { getPeerColorClass } from './helpers/peerColor';
import renderText from './helpers/renderText';
import { getTextWithEntitiesAsHtml } from './helpers/renderTextWithEntities';

Expand Down Expand Up @@ -169,12 +170,12 @@ type OwnProps = {
dropAreaState?: string;
isReady: boolean;
isMobile?: boolean;
onDropHide?: NoneToVoidFunction;
inputId: string;
editableInputCssSelector: string;
editableInputId: string;
className?: string;
inputPlaceholder?: string;
onDropHide?: NoneToVoidFunction;
onForward?: NoneToVoidFunction;
onFocus?: NoneToVoidFunction;
onBlur?: NoneToVoidFunction;
Expand Down Expand Up @@ -205,6 +206,7 @@ type StateProps =
customEmojiForEmoji?: ApiSticker[];
groupChatMembers?: ApiChatMember[];
currentUserId?: string;
currentUser?: ApiUser;
recentEmojis: string[];
contentToBeScheduled?: TabState['contentToBeScheduled'];
shouldSuggestStickers?: boolean;
Expand Down Expand Up @@ -304,6 +306,7 @@ const Composer: FC<OwnProps & StateProps> = ({
groupChatMembers,
topInlineBotIds,
currentUserId,
currentUser,
captionLimit,
contentToBeScheduled,
shouldSuggestStickers,
Expand Down Expand Up @@ -1609,7 +1612,7 @@ const Composer: FC<OwnProps & StateProps> = ({
/>
</>
)}
<div className="message-input-wrapper">
<div className={buildClassName('message-input-wrapper', getPeerColorClass(currentUser))}>
{isInMessageList && (
<>
{withBotMenuButton && (
Expand Down Expand Up @@ -1914,6 +1917,7 @@ export default memo(withGlobal<OwnProps>(
const botKeyboardMessageId = messageWithActualBotKeyboard ? messageWithActualBotKeyboard.id : undefined;
const keyboardMessage = botKeyboardMessageId ? selectChatMessage(global, chatId, botKeyboardMessageId) : undefined;
const { currentUserId } = global;
const currentUser = selectUser(global, currentUserId!)!;
const defaultSendAsId = chatFullInfo ? chatFullInfo?.sendAsId || currentUserId : undefined;
const sendAsId = chat?.sendAsPeerIds && defaultSendAsId && (
chat.sendAsPeerIds.some((peer) => peer.id === defaultSendAsId)
Expand Down Expand Up @@ -1973,6 +1977,7 @@ export default memo(withGlobal<OwnProps>(
groupChatMembers: chatFullInfo?.members,
topInlineBotIds: global.topInlineBots?.userIds,
currentUserId,
currentUser,
contentToBeScheduled: tabState.contentToBeScheduled,
shouldSuggestStickers,
shouldSuggestCustomEmoji,
Expand Down
74 changes: 38 additions & 36 deletions src/components/common/DeleteMessageModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable react/self-closing-comp */
/* eslint-disable max-len */
import type { FC } from '../../lib/teact/teact';
import React, { memo, useCallback } from '../../lib/teact/teact';
import React, { memo, useCallback, useState } from '../../lib/teact/teact';
import { getActions, withGlobal } from '../../global';

import type { ApiMessage } from '../../api/types';
Expand All @@ -25,6 +27,7 @@ import useLang from '../../hooks/useLang';

import Button from '../ui/Button';
import Modal from '../ui/Modal';
import RadioGroup from '../ui/RadioGroup';

export type OwnProps = {
isOpen: boolean;
Expand All @@ -49,8 +52,6 @@ const DeleteMessageModal: FC<OwnProps & StateProps> = ({
album,
canDeleteForAll,
contactName,
willDeleteForCurrentUserOnly,
willDeleteForAll,
onConfirm,
onClose,
}) => {
Expand All @@ -59,57 +60,58 @@ const DeleteMessageModal: FC<OwnProps & StateProps> = ({
deleteScheduledMessages,
} = getActions();

const handleDeleteMessageForAll = useCallback(() => {
onConfirm?.();
const messageIds = album?.messages
? album.messages.map(({ id }) => id)
: [message.id];
deleteMessages({ messageIds, shouldDeleteForAll: true });
onClose();
}, [onConfirm, album, message.id, deleteMessages, onClose]);
const [shouldDeleteForAll, setShouldDeleteForAll] = useState(canDeleteForAll ? 'everyone' : 'me');
const lang = useLang();
const deleteOptions = [
{
label: lang('ChatList.DeleteForCurrentUser'),
value: 'me',
},
{
label: contactName ? renderText(lang('Conversation.DeleteMessagesFor', contactName)) : lang('Conversation.DeleteMessagesForEveryone'),
value: 'everyone',
},
];

const handleDeleteMessageForSelf = useCallback(() => {
const handleDelete = useCallback(() => {
onConfirm?.();
const messageIds = album?.messages
? album.messages.map(({ id }) => id)
: [message.id];
const messageIds = album?.messages ? album.messages.map(({ id }) => id) : [message.id];
if (isSchedule) {
deleteScheduledMessages({ messageIds });
} else {
deleteMessages({
messageIds,
shouldDeleteForAll: false,
});
deleteMessages({ messageIds, shouldDeleteForAll: shouldDeleteForAll === 'everyone' });
}
onClose();
}, [onConfirm, album, message.id, isSchedule, onClose, deleteScheduledMessages, deleteMessages]);
}, [onConfirm, album, message.id, isSchedule, deleteMessages, deleteScheduledMessages, onClose, shouldDeleteForAll]);

const lang = useLang();
const handleRadioChange = useCallback((value: string) => {
setShouldDeleteForAll(value);
}, []);

return (
<Modal
isOpen={isOpen}
onClose={onClose}
onEnter={isOpen && !canDeleteForAll ? handleDeleteMessageForSelf : undefined}
onEnter={handleDelete}
className="delete"
title={lang('DeleteSingleMessagesTitle')}
>
<p>{lang('AreYouSureDeleteSingleMessage')}</p>
{willDeleteForCurrentUserOnly && (
<p>{lang('lng_delete_for_me_chat_hint', 1, 'i')}</p>
)}
{willDeleteForAll && (
<p>{lang('lng_delete_for_everyone_hint', 1, 'i')}</p>
{canDeleteForAll && (
<RadioGroup
name="deleteFor"
options={deleteOptions}
selected={shouldDeleteForAll ? 'everyone' : 'me'}
// eslint-disable-next-line react/jsx-no-bind
onChange={(value) => handleRadioChange(value)}
/>
)}
<div className={canDeleteForAll ? 'dialog-buttons-column' : 'dialog-buttons'}>
{canDeleteForAll && (
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForAll}>
{contactName && renderText(lang('Conversation.DeleteMessagesFor', contactName))}
{!contactName && lang('Conversation.DeleteMessagesForEveryone')}
</Button>
)}
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForSelf}>
{lang(canDeleteForAll ? 'ChatList.DeleteForCurrentUser' : 'Delete')}
<div className="dialog-buttons">
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDelete}>
{lang('Delete')}
<div className="hotkey-frame">
<div className="hotkey-icon"></div>
</div>
</Button>
<Button className="confirm-dialog-button" isText onClick={onClose}>{lang('Cancel')}</Button>
</div>
Expand Down
76 changes: 53 additions & 23 deletions src/components/common/PinMessageModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react/self-closing-comp */
import type { FC } from '../../lib/teact/teact';
import React, { memo, useCallback } from '../../lib/teact/teact';
import React, { memo, useCallback, useState } from '../../lib/teact/teact';
import { getActions, withGlobal } from '../../global';

import {
Expand All @@ -17,6 +18,7 @@ import useLang from '../../hooks/useLang';

import Button from '../ui/Button';
import Modal from '../ui/Modal';
import RadioGroup from '../ui/RadioGroup';

export type OwnProps = {
isOpen: boolean;
Expand Down Expand Up @@ -47,21 +49,31 @@ const PinMessageModal: FC<OwnProps & StateProps> = ({
}) => {
const { pinMessage } = getActions();

const handlePinMessageForAll = useCallback(() => {
pinMessage({
messageId, isUnpin: false,
});
onClose();
}, [pinMessage, messageId, onClose]);
const [pinForAll, setPinForAll] = useState<string>(canPinForAll ? 'everyone' : 'me');

const lang = useLang();

const handlePinMessage = useCallback(() => {
const pinOptions = [
{
label: lang('PinMessageForMe'),
value: 'me',
},
{
// eslint-disable-next-line max-len
label: contactName ? renderText(lang('Conversation.PinMessagesFor', contactName)) : lang('Conversation.PinMessageAlert.PinAndNotifyMembers'),
value: 'everyone',
},
];

const handlePin = useCallback(() => {
pinMessage({
messageId, isUnpin: false, isOneSide: true, isSilent: true,
messageId,
isUnpin: false,
isOneSide: pinForAll === 'me',
isSilent: pinForAll === 'me',
});
onClose();
}, [messageId, onClose, pinMessage]);

const lang = useLang();
}, [pinMessage, messageId, onClose, pinForAll]);

function renderMessage() {
if (isChannel) {
Expand All @@ -75,26 +87,44 @@ const PinMessageModal: FC<OwnProps & StateProps> = ({
return lang('PinMessageAlertChat');
}

const handleRadioChange = (value: string) => {
setPinForAll(value);
};

return (
<Modal
isOpen={isOpen}
onClose={onClose}
onEnter={handlePin}
className="pin"
title={lang('PinMessageAlertTitle')}
>
<p>{renderMessage()}</p>
<div className="dialog-buttons-column">
<Button className="confirm-dialog-button" isText onClick={handlePinMessage}>
{lang('DialogPin')}
<RadioGroup
name="pinFor"
options={pinOptions}
selected={pinForAll}
// eslint-disable-next-line react/jsx-no-bind
onChange={(value) => handleRadioChange(value)}
/>
<div className="dialog-buttons">
<Button
color="primary"
className="confirm-dialog-button"
onClick={handlePin}
>
{lang('PinMessageAlertTitle')}
<div className="hotkey-frame">
<div className="hotkey-icon"></div>
</div>
</Button>
<Button
className="confirm-dialog-button"
isText
onClick={onClose}
>
{lang('Cancel')}
</Button>
{canPinForAll && (
<Button className="confirm-dialog-button" isText onClick={handlePinMessageForAll}>
{contactName
? renderText(lang('Conversation.PinMessagesFor', contactName))
: lang('Conversation.PinMessageAlert.PinAndNotifyMembers')}
</Button>
)}
<Button className="confirm-dialog-button" isText onClick={onClose}>{lang('Cancel')}</Button>
</div>
</Modal>
);
Expand Down
4 changes: 4 additions & 0 deletions src/components/common/ReportModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/self-closing-comp */
import type { ChangeEvent } from 'react';
import type { FC } from '../../lib/teact/teact';
import React, { memo, useMemo, useState } from '../../lib/teact/teact';
Expand Down Expand Up @@ -126,6 +127,9 @@ const ReportModal: FC<OwnProps> = ({
<div className="dialog-buttons">
<Button color="danger" className="confirm-dialog-button" isText onClick={handleReport}>
{lang('lng_report_button')}
<div className="hotkey-frame">
<div className="hotkey-icon"></div>
</div>
</Button>
<Button className="confirm-dialog-button" isText onClick={onClose}>{lang('Cancel')}</Button>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/components/common/embedded/EmbeddedMessage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@
}

&.inside-input {
padding-inline-start: 0.5625rem;
width: 100%;
flex-grow: 1;

.embedded-thumb {
margin-left: 0.125rem;
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/helpers/peerColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getPeerColorCount, getPeerColorKey } from '../../../global/helpers';
export function getPeerColorClass(peer?: ApiPeer, noUserColors?: boolean, shouldReset?: boolean) {
if (!peer) {
if (!shouldReset) return undefined;
return noUserColors ? 'peer-color-count-0' : 'peer-color-0';
return noUserColors ? 'peer-color-count-1' : 'peer-color-0';
}
return noUserColors ? `peer-color-count-${getPeerColorCount(peer)}` : `peer-color-${getPeerColorKey(peer)}`;
}
13 changes: 8 additions & 5 deletions src/components/common/helpers/renderTextWithEntities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,9 @@ function processEntity({
return <strong data-entity-type={entity.type}>{renderNestedMessagePart()}</strong>;
case ApiMessageEntityTypes.Blockquote:
return (
<div className="message-entity-blockquote-wrapper">
<blockquote data-entity-type={entity.type}>
{renderNestedMessagePart()}
</blockquote>
</div>
<blockquote data-entity-type={entity.type}>
{renderNestedMessagePart()}
</blockquote>
);
case ApiMessageEntityTypes.BotCommand:
return (
Expand Down Expand Up @@ -574,6 +572,11 @@ function processEntityAsHtml(
>${renderedContent}</span>`;
case ApiMessageEntityTypes.CustomEmoji:
return buildCustomEmojiHtmlFromEntity(rawEntityText, entity);
case ApiMessageEntityTypes.Blockquote:
return `<span
class="blockquote"
data-entity-type="${ApiMessageEntityTypes.Blockquote}"
>${renderedContent}</span>`;
default:
return renderedContent;
}
Expand Down
Loading

0 comments on commit 32eed8c

Please sign in to comment.