diff --git a/build_output.txt b/build_output.txt
new file mode 100644
index 0000000..a27d77a
Binary files /dev/null and b/build_output.txt differ
diff --git a/src/app/components/emoji-board/EmojiBoard.tsx b/src/app/components/emoji-board/EmojiBoard.tsx
index 825ef58..30da8c7 100644
--- a/src/app/components/emoji-board/EmojiBoard.tsx
+++ b/src/app/components/emoji-board/EmojiBoard.tsx
@@ -21,7 +21,6 @@ import { useEmojiGroupIcons } from './useEmojiGroupIcons';
import { preventScrollWithArrowKey, stopPropagation } from '../../utils/keyboard';
import { useRelevantImagePacks } from '../../hooks/useImagePacks';
import { useMatrixClient } from '../../hooks/useMatrixClient';
-import { useRecentEmoji } from '../../hooks/useRecentEmoji';
import { useEmojiUsage } from '../../hooks/useEmojiUsage';
import { isUserId, mxcUrlToHttp } from '../../utils/matrix';
import { editableActiveElement, targetFromEvent } from '../../utils/dom';
@@ -76,7 +75,6 @@ const useGroups = (
const mx = useMatrixClient();
const { getTopEmojis } = useEmojiUsage();
- const recentEmojis = useRecentEmoji(mx, 21);
const labels = useEmojiGroupLabels();
const emojiGroupItems = useMemo(() => {
@@ -99,12 +97,6 @@ const useGroups = (
}
}
- g.push({
- id: RECENT_GROUP_ID,
- name: 'Recent',
- items: recentEmojis,
- });
-
imagePacks.forEach((pack) => {
let label = pack.meta.name;
if (!label) label = isUserId(pack.id) ? 'Personal Pack' : mx.getRoom(pack.id)?.name;
@@ -127,7 +119,7 @@ const useGroups = (
});
return g;
- }, [mx, recentEmojis, labels, imagePacks, tab]);
+ }, [mx, labels, imagePacks, tab, getTopEmojis]);
const stickerGroupItems = useMemo(() => {
const g: StickerGroupItem[] = [];
@@ -212,13 +204,6 @@ function EmojiSidebar({ activeGroupAtom, packs, onScrollToGroup }: EmojiSidebarP
icon={Icons.Heart}
onClick={handleScrollToGroup}
/>
-
{packs.length > 0 && (
diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx
index 3ab97e8..73c030a 100644
--- a/src/app/components/message/MsgTypeRenderers.tsx
+++ b/src/app/components/message/MsgTypeRenderers.tsx
@@ -81,6 +81,9 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
if (typeof body !== 'string') return ;
const trimmedBody = trimReplyFromBody(body).trim();
+ const trimmedCustomBody = typeof customBody === 'string'
+ ? customBody.trim().replace(/(
\s*)+$/gi, '')
+ : undefined;
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
@@ -93,7 +96,7 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
>
{renderBody({
body: trimmedBody,
- customBody: typeof customBody === 'string' ? customBody : undefined,
+ customBody: trimmedCustomBody,
})}
{edited && }
@@ -119,7 +122,10 @@ export function MEmote({
const { body, formatted_body: customBody } = content;
if (typeof body !== 'string') return ;
- const trimmedBody = trimReplyFromBody(body);
+ const trimmedBody = trimReplyFromBody(body).trim();
+ const trimmedCustomBody = typeof customBody === 'string'
+ ? customBody.trim().replace(/(
\s*)+$/gi, '')
+ : undefined;
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
@@ -133,7 +139,7 @@ export function MEmote({
{`${displayName} `}
{renderBody({
body: trimmedBody,
- customBody: typeof customBody === 'string' ? customBody : undefined,
+ customBody: trimmedCustomBody,
})}
{edited && }
@@ -152,7 +158,10 @@ export function MNotice({ edited, content, renderBody, renderUrlsPreview }: MNot
const { body, formatted_body: customBody } = content;
if (typeof body !== 'string') return ;
- const trimmedBody = trimReplyFromBody(body);
+ const trimmedBody = trimReplyFromBody(body).trim();
+ const trimmedCustomBody = typeof customBody === 'string'
+ ? customBody.trim().replace(/(
\s*)+$/gi, '')
+ : undefined;
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
@@ -165,7 +174,7 @@ export function MNotice({ edited, content, renderBody, renderUrlsPreview }: MNot
>
{renderBody({
body: trimmedBody,
- customBody: typeof customBody === 'string' ? customBody : undefined,
+ customBody: trimmedCustomBody,
})}
{edited && }
diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx
index f5cf99f..8242850 100644
--- a/src/app/features/room/RoomInput.tsx
+++ b/src/app/features/room/RoomInput.tsx
@@ -405,10 +405,10 @@ export const RoomInput = forwardRef(
return;
}
- if (plainText === '') return;
-
let body = plainText.trim();
- let formattedBody = customHtml.trim();
+ let formattedBody = customHtml.trim().replace(/(
\s*)+$/gi, '');
+
+ if (body === '') return;
// Apply emoticon conversion if enabled
if (autoConvertEmoticons) {
diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx
index 45ee558..c5b63dd 100644
--- a/src/app/features/room/message/Message.tsx
+++ b/src/app/features/room/message/Message.tsx
@@ -62,6 +62,8 @@ import {
import { MessageLayout, MessageSpacing } from '../../../state/settings';
import { useMatrixClient } from '../../../hooks/useMatrixClient';
import { useRecentEmoji } from '../../../hooks/useRecentEmoji';
+import { useEmojiUsage } from '../../../hooks/useEmojiUsage';
+import { emojis } from '../../../plugins/emoji';
import * as css from './styles.css';
import { EventReaders } from '../../../components/event-readers';
import { TextViewer } from '../../../components/text-viewer';
@@ -71,8 +73,6 @@ import { ReactionViewer } from '../reaction-viewer';
import { MessageEditor } from './MessageEditor';
import { UserAvatar } from '../../../components/user-avatar';
import { copyToClipboard } from '../../../utils/dom';
-import { useEmojiUsage } from '../../../hooks/useEmojiUsage';
-import { emojis } from '../../../plugins/emoji';
import { stopPropagation } from '../../../utils/keyboard';
import { getMatrixToRoomEvent } from '../../../plugins/matrix-to';
import { getViaServers } from '../../../plugins/via-servers';
@@ -93,10 +93,13 @@ type MessageQuickReactionsProps = {
};
export const MessageQuickReactions = as<'div', MessageQuickReactionsProps>(
({ onReaction, ...props }, ref) => {
- const mx = useMatrixClient();
- const recentEmojis = useRecentEmoji(mx, 4);
+ const { getTopEmojis } = useEmojiUsage();
+ const topShortcodes = getTopEmojis(4);
+ const mostUsedEmojis = topShortcodes
+ .map((shortcode) => emojis.find((e) => e.shortcode === shortcode))
+ .filter((e): e is IEmoji => e !== undefined);
- if (recentEmojis.length === 0) return ;
+ if (mostUsedEmojis.length === 0) return ;
return (
<>
(
{...props}
ref={ref}
>
- {recentEmojis.map((emoji) => (
+ {mostUsedEmojis.map((emoji) => (
(
const useAuthentication = useMediaAuthentication();
const senderId = mEvent.getSender() ?? '';
const senderPresence = useUserPresence(senderId);
- const { getMostUsedEmoji } = useEmojiUsage();
const [hover, setHover] = useState(false);
const { hoverProps } = useHover({ onHoverChange: setHover });
@@ -978,24 +980,6 @@ export const Message = as<'div', MessageProps>(