From 4bd5bc87ee3cf21d5c30b7e077513c8196e6695d Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Sun, 12 Dec 2021 14:56:47 -0500 Subject: [PATCH] Update js/src/common/models/User.ts Co-authored-by: David Wheatley --- js/src/common/models/User.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/src/common/models/User.ts b/js/src/common/models/User.ts index af5a0a823..c1f6a9830 100644 --- a/js/src/common/models/User.ts +++ b/js/src/common/models/User.ts @@ -131,8 +131,7 @@ export default class User extends Model { const image = new Image(); const user = this; - // @ts-expect-error This shouldn't be failing. - image.onload = function (this: HTMLImageElement) { + image.addEventListener('load', function (this: HTMLImageElement) { try { const colorThief = new ColorThief(); user.avatarColor = colorThief.getColor(this); @@ -147,7 +146,7 @@ export default class User extends Model { } user.freshness = new Date(); m.redraw(); - }; + }); image.crossOrigin = 'anonymous'; image.src = this.avatarUrl() ?? ''; }