From ef2be2cf5f188b186f843e9cc6138dd8b9a6caae Mon Sep 17 00:00:00 2001 From: Daniel Gasienica <daniel@signal.org> Date: Tue, 20 Mar 2018 18:20:01 -0400 Subject: [PATCH] Make `MessageView::onUnload` synchronous Our tests rely on that. --- js/views/message_view.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/views/message_view.js b/js/views/message_view.js index e4ae4642515..fcde0c155c1 100644 --- a/js/views/message_view.js +++ b/js/views/message_view.js @@ -231,7 +231,7 @@ setTimeout(this.remove.bind(this), 1000); }, /* jshint ignore:start */ - onUnload: async function() { + onUnload: function() { if (this.avatarView) { this.avatarView.remove(); } @@ -248,8 +248,12 @@ this.timeStampView.remove(); } - const views = await this.loadedAttachmentViews; - views.forEach(view => view.unload()); + // NOTE: We have to do this in the background (`then` instead of `await`) + // as our tests rely on `onUnload` synchronously removing the view from + // the DOM. + // eslint-disable-next-line more/no-then + this.loadAttachmentViews() + .then(views => views.forEach(view => view.unload())); // No need to handle this one, since it listens to 'unload' itself: // this.timerView