Move destroyPersistentWidget to store
This commit is contained in:
@@ -66,15 +66,21 @@ class ActiveWidgetStore extends EventEmitter {
|
||||
if (ev.getType() !== 'im.vector.modular.widgets') return;
|
||||
|
||||
if (ev.getStateKey() === this._persistentWidgetId) {
|
||||
const PersistedElement = sdk.getComponent("elements.PersistedElement");
|
||||
PersistedElement.destroyElement('widget_' + ev.getStateKey());
|
||||
this.setWidgetPersistence(ev.getStateKey(), false);
|
||||
this.delWidgetMessaging(ev.getStateKey());
|
||||
this.delWidgetCapabilities(ev.getStateKey());
|
||||
this.delRoomId(ev.getStateKey());
|
||||
this.destroyPersistentWidget();
|
||||
}
|
||||
}
|
||||
|
||||
destroyPersistentWidget() {
|
||||
const toDeleteId = this._persistentWidgetId;
|
||||
|
||||
const PersistedElement = sdk.getComponent("elements.PersistedElement");
|
||||
PersistedElement.destroyElement('widget_' + toDeleteId);
|
||||
this.setWidgetPersistence(toDeleteId, false);
|
||||
this.delWidgetMessaging(toDeleteId);
|
||||
this.delWidgetCapabilities(toDeleteId);
|
||||
this.delRoomId(toDeleteId);
|
||||
}
|
||||
|
||||
setWidgetPersistence(widgetId, val) {
|
||||
if (this._persistentWidgetId === widgetId && !val) {
|
||||
this._persistentWidgetId = null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
Copyright 2018 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
Reference in New Issue
Block a user