Merge pull request #450 from TheTimeWalker/ios-sticker-sending

Fix iOS stickers by adding widgetData to callAction
This commit is contained in:
Travis Ralston 2021-12-28 13:54:10 -07:00 committed by GitHub
commit 08bd1319c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,
});
}