no need to keep track of promise, fn is internally rate-limited now

This commit is contained in:
Bruno Windels 2020-11-10 14:02:07 +01:00
parent 89c66699d7
commit fd498b3d24

View file

@ -169,7 +169,6 @@ class ComposerViewModel extends ViewModel {
super(); super();
this._roomVM = roomVM; this._roomVM = roomVM;
this._isEmpty = true; this._isEmpty = true;
this._ensureKeyPromise = null;
} }
get isEncrypted() { get isEncrypted() {
@ -192,10 +191,8 @@ class ComposerViewModel extends ViewModel {
async setInput(text) { async setInput(text) {
const wasEmpty = this._isEmpty; const wasEmpty = this._isEmpty;
this._isEmpty = text.length === 0; this._isEmpty = text.length === 0;
if (wasEmpty && !this._isEmpty && !this._ensureKeyPromise) { if (wasEmpty && !this._isEmpty) {
this._ensureKeyPromise = this._roomVM._room.ensureMessageKeyIsShared().then(() => { this._roomVM._room.ensureMessageKeyIsShared();
this._ensureKeyPromise = null;
});
} }
if (wasEmpty !== this._isEmpty) { if (wasEmpty !== this._isEmpty) {
this.emitChange("canSend"); this.emitChange("canSend");