From 3bdad5ddb4f2ddc645525da7d77771e769e994c0 Mon Sep 17 00:00:00 2001 From: Rye Date: Mon, 9 Mar 2026 23:03:19 +0100 Subject: [PATCH 1/4] add functionality to add a sticker you see in a message to the user's sticker pack --- src/app/features/room/message/Message.tsx | 31 +++++++++++++ .../utils/addStickerToDefaultStickerPack.ts | 46 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/app/utils/addStickerToDefaultStickerPack.ts diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index a556ee0a1..b1dc66345 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -80,6 +80,10 @@ import { MessageDeleteItem } from '$components/message/modals/MessageDelete'; import { MessageReportItem } from '$components/message/modals/MessageReport'; import { filterPronounsByLanguage } from '$utils/pronouns'; import { useMentionClickHandler } from '$hooks/useMentionClickHandler'; +import { + addStickerToDefaultPack, + doesStickerExistInDefaultPack, +} from '$utils/addStickerToDefaultStickerPack'; import { MessageEditor } from './MessageEditor'; import * as css from './styles.css'; @@ -649,6 +653,7 @@ function MessageInternal( }); const isThreadedMessage = mEvent.threadRootId !== undefined; + const isStickerMessage = mEvent.getType() === 'm.sticker'; return ( )} + {isStickerMessage && + !doesStickerExistInDefaultPack(mx, mEvent.getContent().url) && ( + } + radii="300" + onClick={() => { + addStickerToDefaultPack( + mx, + `sticker-${mEvent.getId()}`, + mEvent.getContent().url, + mEvent.getContent().info?.mimetype ?? 'image/png' + ); + closeMenu(); + }} + > + + Add your User Sticker Pack + + + )} {relations && } () ?? {}; + + // modified content with the new sticker added. + // We add the new sticker under the "images" key, using the shortcode as the key for the sticker. + // The sticker content includes the mxc URL, body, info, and usage (which we set to "sticker"). + const next: PackContent = { + ...current, + images: { + ...(current.images ?? {}), + [shortcode]: { + ...(current.images?.[shortcode] ?? {}), + url: mxc, + body, + info, + usage: [ImageUsage.Sticker], + }, + }, + }; + + // update the account data with the modified content, which effectively adds the new sticker to the default sticker pack. + await mx.setAccountData(AccountDataEvent.PoniesUserEmotes, next); +} + +// check if a sticker exists in the account sticker pack +export function doesStickerExistInDefaultPack(mx: MatrixClient, mxc: string) { + const imgs = mx + .getAccountData(AccountDataEvent.PoniesUserEmotes) + ?.getContent().images; + if (imgs === undefined) return false; + return Object.values(imgs).some((image) => image.url === mxc) ?? false; +} From e4fb834402ad471cb1302bf63bc19b6d04977cac Mon Sep 17 00:00:00 2001 From: Rose Date: Mon, 9 Mar 2026 23:10:04 +0100 Subject: [PATCH 2/4] added Changeset --- ...ker_you_see_in_a_message_to_your_own_user_sticker_pack.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/add_button_to_add_a_sticker_you_see_in_a_message_to_your_own_user_sticker_pack.md diff --git a/.changeset/add_button_to_add_a_sticker_you_see_in_a_message_to_your_own_user_sticker_pack.md b/.changeset/add_button_to_add_a_sticker_you_see_in_a_message_to_your_own_user_sticker_pack.md new file mode 100644 index 000000000..e416559ac --- /dev/null +++ b/.changeset/add_button_to_add_a_sticker_you_see_in_a_message_to_your_own_user_sticker_pack.md @@ -0,0 +1,5 @@ +--- +sable: minor +--- + +add button to save a sticker you see in the message timeline to your personal account sticker pack From a9595ba2160082dfd46087d553262267b4b84b57 Mon Sep 17 00:00:00 2001 From: Rye Date: Mon, 9 Mar 2026 23:25:36 +0100 Subject: [PATCH 3/4] fix of issue where the mimetype was swapped with the body --- src/app/features/room/message/Message.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index b1dc66345..98f16a24f 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -808,7 +808,8 @@ function MessageInternal( mx, `sticker-${mEvent.getId()}`, mEvent.getContent().url, - mEvent.getContent().info?.mimetype ?? 'image/png' + mEvent.getContent().body, + mEvent.getContent().info ); closeMenu(); }} From 6f56e4fb07500b3da9dbad3e91497e762fdd46d3 Mon Sep 17 00:00:00 2001 From: Rye Date: Mon, 9 Mar 2026 23:28:55 +0100 Subject: [PATCH 4/4] fix spelling mistake lol --- src/app/features/room/message/Message.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 98f16a24f..f89297d66 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -820,7 +820,7 @@ function MessageInternal( size="T300" truncate > - Add your User Sticker Pack + Add to User Sticker Pack )}