From 835c95e6e29ae370db2a08696b98cdc0dc42e94b Mon Sep 17 00:00:00 2001 From: Tony Stipanic Date: Thu, 2 Dec 2021 20:15:59 +0100 Subject: [PATCH] Fix iOS stickers by adding widgetData to callAction --- .../services/scalar/scalar-widget.api.ts | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/web/app/shared/services/scalar/scalar-widget.api.ts b/web/app/shared/services/scalar/scalar-widget.api.ts index b743db6..e3c0e51 100644 --- a/web/app/shared/services/scalar/scalar-widget.api.ts +++ b/web/app/shared/services/scalar/scalar-widget.api.ts @@ -39,33 +39,36 @@ export class ScalarWidgetApi { } public static sendSticker(sticker: FE_Sticker, pack: FE_StickerPack): void { - ScalarWidgetApi.callAction("m.sticker", { - data: { - description: sticker.description, - content: { - // Element Android requires content.body to contain the sticker description, otherwise - // you will not be able to send any stickers - body: sticker.description, - url: sticker.thumbnail.mxc, - info: { + const payload = { + description: sticker.description, + content: { + // Element Android requires content.body to contain the sticker description, otherwise + // you will not be able to send any stickers + body: sticker.description, + url: sticker.thumbnail.mxc, + info: { + mimetype: sticker.image.mimetype, + w: Math.round(sticker.thumbnail.width / 2), + h: Math.round(sticker.thumbnail.height / 2), + thumbnail_url: sticker.thumbnail.mxc, + thumbnail_info: { mimetype: sticker.image.mimetype, w: Math.round(sticker.thumbnail.width / 2), h: Math.round(sticker.thumbnail.height / 2), - thumbnail_url: sticker.thumbnail.mxc, - thumbnail_info: { - mimetype: sticker.image.mimetype, - w: Math.round(sticker.thumbnail.width / 2), - h: Math.round(sticker.thumbnail.height / 2), - }, + }, - // This has to be included in the info object so it makes it to the event - dimension: { - license: pack.license, - author: pack.author, - }, + // This has to be included in the info object so it makes it to the event + dimension: { + license: pack.license, + author: pack.author, }, }, }, + }; + ScalarWidgetApi.callAction("m.sticker", { + data: payload, + // This is needed for Element iOS to work as it uses widgetData + widgetData: payload, }); }