forked from ProfessionalUwU/stickerpicker
Add more Element iOS compatibility (ref #8)
This commit is contained in:
@ -34,14 +34,28 @@ window.onmessage = event => {
|
||||
}
|
||||
|
||||
export function sendSticker(content) {
|
||||
const data = {
|
||||
content,
|
||||
// `name` is for Element Web (and also the spec)
|
||||
// Element Android uses content -> body as the name
|
||||
name: content.body,
|
||||
}
|
||||
|
||||
// This is for Element iOS
|
||||
const widgetData = {
|
||||
...data,
|
||||
description: content.body,
|
||||
file: `${content["net.maunium.telegram.sticker"].id}.png`,
|
||||
}
|
||||
// Element iOS explodes if there are extra fields present
|
||||
delete widgetData.content["net.maunium.telegram.sticker"]
|
||||
|
||||
window.parent.postMessage({
|
||||
api: "fromWidget",
|
||||
action: "m.sticker",
|
||||
requestId: `sticker-${Date.now()}`,
|
||||
widgetId,
|
||||
data: {
|
||||
name: content.body,
|
||||
content,
|
||||
},
|
||||
data,
|
||||
widgetData,
|
||||
}, "*")
|
||||
}
|
||||
|
Reference in New Issue
Block a user