From 9107facaca414f5f3ea6cf5cb306fb0fa241e1bd Mon Sep 17 00:00:00 2001
From: xj9 <xj9@heropunch.io>
Date: Thu, 2 Mar 2017 20:01:19 -0700
Subject: [PATCH] issue #1 - better nsfw image loading

preload the image when it is toggled, but wait to replace it until
it has loaded.
---
 .gitignore                              | 1 +
 src/components/attachment/attachment.js | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index bc9103de..faf39252 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ npm-debug.log
 test/unit/coverage
 test/e2e/reports
 selenium-debug.log
+.idea/
diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js
index f4f6aebf..c3f52f57 100644
--- a/src/components/attachment/attachment.js
+++ b/src/components/attachment/attachment.js
@@ -29,7 +29,11 @@ const Attachment = {
       }
     },
     toggleHidden () {
-      this.showHidden = !this.showHidden
+      let img = document.createElement('img')
+      img.src = this.attachment.url
+      img.onload = () => {
+        this.showHidden = !this.showHidden
+      }
     }
   }
 }