From b42f7e1a361727c9fc6682efcf9d1f5f9ce0614d Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 29 Jun 2021 19:48:36 +0530 Subject: [PATCH] remove both handlers Signed-off-by: RMidhunSuresh --- src/platform/web/ui/avatar.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/platform/web/ui/avatar.js b/src/platform/web/ui/avatar.js index 0a865963..d01a026e 100644 --- a/src/platform/web/ui/avatar.js +++ b/src/platform/web/ui/avatar.js @@ -58,17 +58,14 @@ export class AvatarView extends BaseUpdateView { } _addListenersToAvatar(image) { - const handleAvatarError = (e) => { + const imageEventHandler = (e) => { + if(e.type === "error") { this._setAvatarError(); } const image = e.target; - image.removeEventListener("load", removeErrorHandler); - this._setAvatarError(); + image.removeEventListener("error", imageEventHandler); + image.removeEventListener("load", imageEventHandler); }; - const removeErrorHandler = (e) => { - const image = e.target; - image.removeEventListener("error", handleAvatarError); - }; - image?.addEventListener("error", handleAvatarError); - image?.addEventListener("load", removeErrorHandler); + image?.addEventListener("error", imageEventHandler); + image?.addEventListener("load", imageEventHandler); } _avatarLetterChanged() {