From 73a635413515f2d113e466d0594c606a005460f5 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 6 Jan 2022 10:05:15 +0000 Subject: [PATCH] Fixed "calling .set on destroyed object" error in gh-image-uploader tests refs https://github.com/TryGhost/Admin/pull/2041 - the pretender upgrade highlighted an issue with the component's progress event handler where it could fire and attempt to set the progress property after the component has been destroyed --- ghost/admin/app/components/gh-image-uploader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ghost/admin/app/components/gh-image-uploader.js b/ghost/admin/app/components/gh-image-uploader.js index d70bebb36c..2d7de271a7 100644 --- a/ghost/admin/app/components/gh-image-uploader.js +++ b/ghost/admin/app/components/gh-image-uploader.js @@ -204,7 +204,9 @@ export default Component.extend({ if (event.lengthComputable) { run(() => { let percentage = Math.round((event.loaded / event.total) * 100); - this.set('uploadPercentage', percentage); + if (!this.isDestroyed && !this.isDestroying) { + this.set('uploadPercentage', percentage); + } }); } },