Make AppTile in Stickerpicker persistent using PersistedElement

This commit is contained in:
Luke Barnard 2018-05-11 15:07:51 +01:00
parent 6500797d2a
commit 746eeee33c
2 changed files with 123 additions and 0 deletions

View file

@ -150,6 +150,11 @@ export default class Stickerpicker extends React.Component {
const stickerpickerWidget = this.state.stickerpickerWidget;
let stickersContent;
// Use a separate ReactDOM tree to render the AppTile separately so that it persists and does
// not unmount when we (a) close the sticker picker (b) switch rooms. It's properties are still
// updated.
const PersistedElement = sdk.getComponent("elements.PersistedElement");
// Load stickerpack content
if (stickerpickerWidget && stickerpickerWidget.content && stickerpickerWidget.content.url) {
// Set default name
@ -166,6 +171,7 @@ export default class Stickerpicker extends React.Component {
width: this.popoverWidth,
}}
>
<PersistedElement>
<AppTile
id={stickerpickerWidget.id}
url={stickerpickerWidget.content.url}
@ -189,6 +195,7 @@ export default class Stickerpicker extends React.Component {
whitelistCapabilities={['m.sticker']}
userWidget={true}
/>
</PersistedElement>
</div>
</div>
);