Hashtag: Support click on hashtag with username (#5160)
This commit is contained in:
parent
5b3c783e25
commit
e62e78f968
@ -473,10 +473,11 @@ function processEntity({
|
||||
{renderNestedMessagePart()}
|
||||
</a>
|
||||
);
|
||||
case ApiMessageEntityTypes.Hashtag:
|
||||
case ApiMessageEntityTypes.Hashtag: {
|
||||
const [tag, username] = entityContent.split('@');
|
||||
return (
|
||||
<a
|
||||
onClick={handleHashtagClick}
|
||||
onClick={() => handleHashtagClick(tag, username)}
|
||||
className="text-entity-link"
|
||||
dir="auto"
|
||||
data-entity-type={entity.type}
|
||||
@ -484,10 +485,12 @@ function processEntity({
|
||||
{renderNestedMessagePart()}
|
||||
</a>
|
||||
);
|
||||
case ApiMessageEntityTypes.Cashtag:
|
||||
}
|
||||
case ApiMessageEntityTypes.Cashtag: {
|
||||
const [tag, username] = entityContent.split('@');
|
||||
return (
|
||||
<a
|
||||
onClick={handleHashtagClick}
|
||||
onClick={() => handleHashtagClick(tag, username)}
|
||||
className="text-entity-link"
|
||||
dir="auto"
|
||||
data-entity-type={entity.type}
|
||||
@ -495,6 +498,7 @@ function processEntity({
|
||||
{renderNestedMessagePart()}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
case ApiMessageEntityTypes.Code:
|
||||
return (
|
||||
<code
|
||||
@ -658,8 +662,19 @@ function handleBotCommandClick(e: React.MouseEvent<HTMLAnchorElement>) {
|
||||
getActions().sendBotCommand({ command: e.currentTarget.innerText });
|
||||
}
|
||||
|
||||
function handleHashtagClick(e: React.MouseEvent<HTMLAnchorElement>) {
|
||||
getActions().searchHashtag({ hashtag: e.currentTarget.innerText });
|
||||
function handleHashtagClick(hashtag?: string, username?: string) {
|
||||
if (!hashtag) return;
|
||||
if (username) {
|
||||
getActions().openChatByUsername({
|
||||
username,
|
||||
onChatChanged: {
|
||||
action: 'searchHashtag',
|
||||
payload: { hashtag },
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
getActions().searchHashtag({ hashtag });
|
||||
}
|
||||
|
||||
function handleCodeClick(e: React.MouseEvent<HTMLElement>) {
|
||||
|
||||
@ -1500,7 +1500,8 @@ addActionHandler('acceptChatInvite', async (global, actions, payload): Promise<v
|
||||
|
||||
addActionHandler('openChatByUsername', async (global, actions, payload): Promise<void> => {
|
||||
const {
|
||||
username, messageId, commentId, startParam, startAttach, attach, threadId, originalParts, startApp, text,
|
||||
username, messageId, commentId, startParam, startAttach, attach, threadId, originalParts, startApp,
|
||||
text, onChatChanged,
|
||||
tabId = getCurrentTabId(),
|
||||
} = payload;
|
||||
|
||||
@ -1542,6 +1543,10 @@ addActionHandler('openChatByUsername', async (global, actions, payload): Promise
|
||||
text,
|
||||
}, tabId,
|
||||
);
|
||||
if (onChatChanged) {
|
||||
// @ts-ignore
|
||||
actions[onChatChanged.action](onChatChanged.payload);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1586,6 +1591,10 @@ addActionHandler('openChatByUsername', async (global, actions, payload): Promise
|
||||
tabId,
|
||||
focusMessageId: commentId,
|
||||
});
|
||||
if (onChatChanged) {
|
||||
// @ts-ignore
|
||||
actions[onChatChanged.action](onChatChanged.payload);
|
||||
}
|
||||
});
|
||||
|
||||
addActionHandler('togglePreHistoryHidden', async (global, actions, payload): Promise<void> => {
|
||||
|
||||
@ -1828,6 +1828,7 @@ export interface ActionPayloads {
|
||||
startApp?: string;
|
||||
text?: string;
|
||||
originalParts?: (string | undefined)[];
|
||||
onChatChanged?: CallbackAction;
|
||||
} & WithTabId;
|
||||
processBoostParameters: {
|
||||
usernameOrId: string;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user