Various fixes (#4553)

This commit is contained in:
Alexander Zinchuk 2024-05-14 04:23:52 +02:00
parent c610c5ca73
commit 115ca399df
10 changed files with 40 additions and 24 deletions

View File

@ -217,7 +217,7 @@ const ChatExtra: FC<OwnProps & StateProps> = ({
const handlePhoneClick = useLastCallback(() => { const handlePhoneClick = useLastCallback(() => {
if (phoneNumber?.length === FRAGMENT_PHONE_LENGTH && phoneNumber.startsWith(FRAGMENT_PHONE_CODE)) { if (phoneNumber?.length === FRAGMENT_PHONE_LENGTH && phoneNumber.startsWith(FRAGMENT_PHONE_CODE)) {
requestCollectibleInfo({ collectible: phoneNumber, userId: userId!, type: 'phone' }); requestCollectibleInfo({ collectible: phoneNumber, peerId: peerId!, type: 'phone' });
return; return;
} }
copy(formattedNumber!, lang('Phone')); copy(formattedNumber!, lang('Phone'));
@ -225,7 +225,7 @@ const ChatExtra: FC<OwnProps & StateProps> = ({
const handleUsernameClick = useLastCallback((username: ApiUsername, isChat?: boolean) => { const handleUsernameClick = useLastCallback((username: ApiUsername, isChat?: boolean) => {
if (!username.isEditable) { if (!username.isEditable) {
requestCollectibleInfo({ collectible: username.username, userId: userId!, type: 'username' }); requestCollectibleInfo({ collectible: username.username, peerId: peerId!, type: 'username' });
return; return;
} }
copy(formatUsername(username.username, isChat), lang(isChat ? 'Link' : 'Username')); copy(formatUsername(username.username, isChat), lang(isChat ? 'Link' : 'Username'));

View File

@ -196,14 +196,20 @@ const ChatResults: FC<OwnProps & StateProps> = ({
return MEMO_EMPTY_ARRAY; return MEMO_EMPTY_ARRAY;
} }
// No need for expensive global updates, so we avoid them
const chatsById = getGlobal().chats.byId;
return foundIds return foundIds
.map((id) => { .map((id) => {
const [chatId, messageId] = id.split('_'); const [chatId, messageId] = id.split('_');
const chat = chatsById[chatId];
if (!chat) return undefined;
if (isChannelList && !isChatChannel(chat)) return undefined;
return globalMessagesByChatId?.[chatId]?.byId[Number(messageId)]; return globalMessagesByChatId?.[chatId]?.byId[Number(messageId)];
}) })
.filter(Boolean); .filter(Boolean);
}, [foundIds, globalMessagesByChatId, searchQuery, searchDate]); }, [searchQuery, searchDate, foundIds, isChannelList, globalMessagesByChatId]);
const handleClickShowMoreLocal = useCallback(() => { const handleClickShowMoreLocal = useCallback(() => {
setShouldShowMoreLocal(!shouldShowMoreLocal); setShouldShowMoreLocal(!shouldShowMoreLocal);

View File

@ -33,10 +33,13 @@
position: relative; position: relative;
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: hidden;
border-radius: 0.25rem;
} }
&--stickers { &--stickers {
color: var(--accent-color); color: var(--accent-color);
border-radius: 0 !important;
} }
&.in-preview { &.in-preview {

View File

@ -34,7 +34,7 @@ import './WebPage.scss';
const MAX_TEXT_LENGTH = 170; // symbols const MAX_TEXT_LENGTH = 170; // symbols
const WEBPAGE_STORY_TYPE = 'telegram_story'; const WEBPAGE_STORY_TYPE = 'telegram_story';
const STICKER_SIZE = 80; const STICKER_SIZE = 80;
const EMOJI_SIZE = 40; const EMOJI_SIZE = 38;
type OwnProps = { type OwnProps = {
message: ApiMessage; message: ApiMessage;

View File

@ -56,7 +56,7 @@ const CollectibleInfoModal: FC<OwnProps & StateProps> = ({
}); });
const handleOpenChat = useLastCallback(() => { const handleOpenChat = useLastCallback(() => {
openChat({ id: modal!.userId }); openChat({ id: modal!.peerId });
handleClose(); handleClose();
}); });
@ -126,14 +126,14 @@ const CollectibleInfoModal: FC<OwnProps & StateProps> = ({
<PickerSelectedItem <PickerSelectedItem
fluid fluid
className={styles.chip} className={styles.chip}
peerId={modal?.userId} peerId={modal?.peerId}
forceShowSelf forceShowSelf
onClick={handleOpenChat} onClick={handleOpenChat}
/> />
<p className={styles.description}> <p className={styles.description}>
{description && renderText(description, ['simple_markdown'])} {description && renderText(description, ['simple_markdown'])}
</p> </p>
<div className="dialog-buttons"> <div className="dialog-buttons dialog-buttons-centered">
<Button className="confirm-dialog-button" onClick={handleOpenUrl}> <Button className="confirm-dialog-button" onClick={handleOpenUrl}>
{lang('FragmentUsernameOpen')} {lang('FragmentUsernameOpen')}
</Button> </Button>

View File

@ -45,6 +45,7 @@ type StateProps = {
isSignaturesShown: boolean; isSignaturesShown: boolean;
canChangeInfo?: boolean; canChangeInfo?: boolean;
canInvite?: boolean; canInvite?: boolean;
canPost?: boolean;
exportedInvites?: ApiExportedInvite[]; exportedInvites?: ApiExportedInvite[];
availableReactions?: ApiAvailableReaction[]; availableReactions?: ApiAvailableReaction[];
}; };
@ -60,6 +61,7 @@ const ManageChannel: FC<OwnProps & StateProps> = ({
isSignaturesShown, isSignaturesShown,
canChangeInfo, canChangeInfo,
canInvite, canInvite,
canPost,
exportedInvites, exportedInvites,
isActive, isActive,
availableReactions, availableReactions,
@ -97,10 +99,11 @@ const ManageChannel: FC<OwnProps & StateProps> = ({
}); });
useEffect(() => { useEffect(() => {
if (!canInvite) return;
loadExportedChatInvites({ chatId }); loadExportedChatInvites({ chatId });
loadExportedChatInvites({ chatId, isRevoked: true }); loadExportedChatInvites({ chatId, isRevoked: true });
loadChatJoinRequests({ chatId }); loadChatJoinRequests({ chatId });
}, [chatId]); }, [chatId, canInvite]);
useEffect(() => { useEffect(() => {
if (progress === ManagementProgress.Complete) { if (progress === ManagementProgress.Complete) {
@ -295,13 +298,15 @@ const ManageChannel: FC<OwnProps & StateProps> = ({
{chatReactionsDescription} {chatReactionsDescription}
</span> </span>
</ListItem> </ListItem>
<div className="ListItem narrow"> {canPost && (
<Checkbox <div className="ListItem narrow">
checked={isSignaturesShown} <Checkbox
label={lang('ChannelSignMessages')} checked={isSignaturesShown}
onChange={handleToggleSignatures} label={lang('ChannelSignMessages')}
/> onChange={handleToggleSignatures}
</div> />
</div>
)}
</div> </div>
<div className="section"> <div className="section">
<ListItem <ListItem
@ -375,6 +380,7 @@ export default memo(withGlobal<OwnProps>(
isSignaturesShown, isSignaturesShown,
canChangeInfo: getHasAdminRight(chat, 'changeInfo'), canChangeInfo: getHasAdminRight(chat, 'changeInfo'),
canInvite: getHasAdminRight(chat, 'inviteUsers'), canInvite: getHasAdminRight(chat, 'inviteUsers'),
canPost: getHasAdminRight(chat, 'postMessages'),
exportedInvites: invites, exportedInvites: invites,
availableReactions: global.reactions.availableReactions, availableReactions: global.reactions.availableReactions,
}; };

View File

@ -183,10 +183,7 @@
flex-direction: row-reverse; flex-direction: row-reverse;
justify-content: flex-start; justify-content: flex-start;
flex-wrap: wrap; flex-wrap: wrap;
gap: 0.5rem 1rem;
.confirm-dialog-button + .confirm-dialog-button {
margin-right: 1rem;
}
} }
.dialog-buttons-column { .dialog-buttons-column {
@ -195,6 +192,10 @@
align-items: flex-end; align-items: flex-end;
} }
.dialog-buttons-centered {
justify-content: center;
}
.dialog-checkbox { .dialog-checkbox {
margin: 1rem 0; margin: 1rem 0;
} }

View File

@ -2687,7 +2687,7 @@ addActionHandler('resolveBusinessChatLink', async (global, actions, payload): Pr
addActionHandler('requestCollectibleInfo', async (global, actions, payload): Promise<void> => { addActionHandler('requestCollectibleInfo', async (global, actions, payload): Promise<void> => {
const { const {
type, collectible, userId, tabId = getCurrentTabId(), type, collectible, peerId, tabId = getCurrentTabId(),
} = payload; } = payload;
let inputCollectible; let inputCollectible;
@ -2711,7 +2711,7 @@ addActionHandler('requestCollectibleInfo', async (global, actions, payload): Pro
...result, ...result,
type, type,
collectible, collectible,
userId, peerId,
}, },
}, tabId); }, tabId);
setGlobal(global); setGlobal(global);

View File

@ -406,7 +406,7 @@ export function filterChatsByName(
return searchWords(translatedTitle) || searchWords(chat.title); return searchWords(translatedTitle) || searchWords(chat.title);
} }
return searchWords(translatedTitle); return searchWords(translatedTitle) || Boolean(chat.usernames?.find(({ username }) => searchWords(username)));
}); });
} }

View File

@ -741,7 +741,7 @@ export type TabState = {
}; };
collectibleInfoModal?: ApiCollectionInfo & { collectibleInfoModal?: ApiCollectionInfo & {
userId: string; peerId: string;
type: 'phone' | 'username'; type: 'phone' | 'username';
collectible: string; collectible: string;
}; };
@ -2878,7 +2878,7 @@ export interface ActionPayloads {
closeOneTimeMediaModal: WithTabId | undefined; closeOneTimeMediaModal: WithTabId | undefined;
requestCollectibleInfo: { requestCollectibleInfo: {
userId: string; peerId: string;
type : 'phone' | 'username'; type : 'phone' | 'username';
collectible: string; collectible: string;
} & WithTabId; } & WithTabId;