From b195ce12e1fcf28ea1e74a1231f9a31dcf71af0b Mon Sep 17 00:00:00 2001
From: ValD <maghtpol@gmail.com>
Date: Wed, 12 Dec 2018 02:28:36 +0530
Subject: preload nsfw image

---
 src/components/attachment/attachment.vue | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'src/components/attachment/attachment.vue')

diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue
index 40e2cf1b..6c8a04ed 100644
--- a/src/components/attachment/attachment.vue
+++ b/src/components/attachment/attachment.vue
@@ -10,7 +10,7 @@
       <a href="#" @click.prevent="toggleHidden()">Hide</a>
     </div>
 
-    <a v-if="type === 'image' && !hidden" class="image-attachment" :href="attachment.url" target="_blank" :title="attachment.description">
+    <a v-if="type === 'image'" class="image-attachment" :class="{'hidden': hidden}" :href="attachment.url" target="_blank" :title="attachment.description">
       <StillImage :class="{'small': isSmall}" referrerpolicy="no-referrer" :mimetype="attachment.mimetype" :src="attachment.large_thumb_url || attachment.url"/>
     </a>
 
@@ -161,6 +161,10 @@
     display: flex;
     flex: 1;
 
+    &.hidden {
+      display: none;
+    }
+
     .still-image {
       width: 100%;
       height: 100%;
-- 
cgit v1.2.3-70-g09d2


From 7b4e08dd93520e3dc1113d76e097b998d12b0f3c Mon Sep 17 00:00:00 2001
From: ValD <maghtpol@gmail.com>
Date: Wed, 12 Dec 2018 03:33:53 +0530
Subject: added config for preload and made attachment responsive to it

---
 src/components/attachment/attachment.js  | 3 ++-
 src/components/attachment/attachment.vue | 3 +--
 src/components/settings/settings.js      | 4 ++++
 src/components/settings/settings.vue     | 4 ++++
 src/i18n/en.json                         | 1 +
 src/modules/config.js                    | 1 +
 6 files changed, 13 insertions(+), 3 deletions(-)

(limited to 'src/components/attachment/attachment.vue')

diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js
index 41730720..71ef2ca4 100644
--- a/src/components/attachment/attachment.js
+++ b/src/components/attachment/attachment.js
@@ -13,6 +13,7 @@ const Attachment = {
     return {
       nsfwImage,
       hideNsfwLocal: this.$store.state.config.hideNsfw,
+      preloadNsfwImage: this.$store.state.config.preloadNsfwImage,
       loopVideo: this.$store.state.config.loopVideo,
       showHidden: false,
       loading: false,
@@ -27,7 +28,7 @@ const Attachment = {
       return fileTypeService.fileType(this.attachment.mimetype)
     },
     hidden () {
-      return this.nsfw && this.hideNsfwLocal && !this.showHidden
+      return (this.nsfw && this.hideNsfwLocal && !this.showHidden)
     },
     isEmpty () {
       return (this.type === 'html' && !this.attachment.oembed) || this.type === 'unknown'
diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue
index 6c8a04ed..1b1956e0 100644
--- a/src/components/attachment/attachment.vue
+++ b/src/components/attachment/attachment.vue
@@ -9,8 +9,7 @@
     <div class="hider" v-if="nsfw && hideNsfwLocal && !hidden">
       <a href="#" @click.prevent="toggleHidden()">Hide</a>
     </div>
-
-    <a v-if="type === 'image'" class="image-attachment" :class="{'hidden': hidden}" :href="attachment.url" target="_blank" :title="attachment.description">
+    <a v-if="type === 'image' && (!hidden || preloadNsfwImage)" class="image-attachment" :class="{'hidden': hidden && preloadNsfwImage}" :href="attachment.url" target="_blank" :title="attachment.description">
       <StillImage :class="{'small': isSmall}" referrerpolicy="no-referrer" :mimetype="attachment.mimetype" :src="attachment.large_thumb_url || attachment.url"/>
     </a>
 
diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js
index 19bd2e5b..4d8744da 100644
--- a/src/components/settings/settings.js
+++ b/src/components/settings/settings.js
@@ -14,6 +14,7 @@ const settings = {
       hideAttachmentsInConvLocal: user.hideAttachmentsInConv,
       hideNsfwLocal: user.hideNsfw,
       hideISPLocal: user.hideISP,
+      preloadNsfwImage: user.preloadNsfwImage,
       hidePostStatsLocal: typeof user.hidePostStats === 'undefined'
         ? instance.hidePostStats
         : user.hidePostStats,
@@ -84,6 +85,9 @@ const settings = {
     hideNsfwLocal (value) {
       this.$store.dispatch('setOption', { name: 'hideNsfw', value })
     },
+    preloadNsfwImage(value) {
+      this.$store.dispatch('setOption', { name: 'preloadNsfwImage', value })
+    },
     hideISPLocal (value) {
       this.$store.dispatch('setOption', { name: 'hideISP', value })
     },
diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue
index dec33505..60b70227 100644
--- a/src/components/settings/settings.vue
+++ b/src/components/settings/settings.vue
@@ -118,6 +118,10 @@
               <input type="checkbox" id="hideNsfw" v-model="hideNsfwLocal">
               <label for="hideNsfw">{{$t('settings.nsfw_clickthrough')}}</label>
             </li>
+            <li>
+              <input type="checkbox" id="preloadNsfwImage" v-model="preloadNsfwImage">
+              <label for="preloadNsfwImage">{{$t('settings.preload_sensitive')}}</label>
+            </li>
             <li>
               <input type="checkbox" id="stopGifs" v-model="stopGifs">
               <label for="stopGifs">{{$t('settings.stop_gifs')}}</label>
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 97dfcb77..dc47788c 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -125,6 +125,7 @@
     "hide_attachments_in_convo": "Hide attachments in conversations",
     "hide_attachments_in_tl": "Hide attachments in timeline",
     "hide_isp": "Hide instance-specific panel",
+    "preload_sensitive": "Preload Sensitive Images",
     "hide_post_stats": "Hide post statistics (e.g. the number of favorites)",
     "hide_user_stats": "Hide user statistics (e.g. the number of followers)",
     "import_followers_from_a_csv_file": "Import follows from a csv file",
diff --git a/src/modules/config.js b/src/modules/config.js
index 45ac8f65..7b0b2cf4 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -9,6 +9,7 @@ const defaultState = {
   hideAttachments: false,
   hideAttachmentsInConv: false,
   hideNsfw: true,
+  preloadNsfwImage: true,
   loopVideo: true,
   loopVideoSilentOnly: true,
   autoLoad: true,
-- 
cgit v1.2.3-70-g09d2


From 139659d42ca0a877843a4fa1606435dd6f6442db Mon Sep 17 00:00:00 2001
From: ValD <maghtpol@gmail.com>
Date: Wed, 12 Dec 2018 03:42:29 +0530
Subject: renamed config to preload images and add ident to config

---
 src/components/attachment/attachment.js  |  2 +-
 src/components/attachment/attachment.vue |  2 +-
 src/components/settings/settings.js      |  6 +++---
 src/components/settings/settings.vue     | 10 ++++++----
 src/i18n/en.json                         |  2 +-
 src/modules/config.js                    |  2 +-
 6 files changed, 13 insertions(+), 11 deletions(-)

(limited to 'src/components/attachment/attachment.vue')

diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js
index 71ef2ca4..fd9a2057 100644
--- a/src/components/attachment/attachment.js
+++ b/src/components/attachment/attachment.js
@@ -13,7 +13,7 @@ const Attachment = {
     return {
       nsfwImage,
       hideNsfwLocal: this.$store.state.config.hideNsfw,
-      preloadNsfwImage: this.$store.state.config.preloadNsfwImage,
+      preloadImage: this.$store.state.config.preloadImage,
       loopVideo: this.$store.state.config.loopVideo,
       showHidden: false,
       loading: false,
diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue
index 1b1956e0..5eaa0d1d 100644
--- a/src/components/attachment/attachment.vue
+++ b/src/components/attachment/attachment.vue
@@ -9,7 +9,7 @@
     <div class="hider" v-if="nsfw && hideNsfwLocal && !hidden">
       <a href="#" @click.prevent="toggleHidden()">Hide</a>
     </div>
-    <a v-if="type === 'image' && (!hidden || preloadNsfwImage)" class="image-attachment" :class="{'hidden': hidden && preloadNsfwImage}" :href="attachment.url" target="_blank" :title="attachment.description">
+    <a v-if="type === 'image' && (!hidden || preloadImage)" class="image-attachment" :class="{'hidden': hidden && preloadImage}" :href="attachment.url" target="_blank" :title="attachment.description">
       <StillImage :class="{'small': isSmall}" referrerpolicy="no-referrer" :mimetype="attachment.mimetype" :src="attachment.large_thumb_url || attachment.url"/>
     </a>
 
diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js
index 4d8744da..9a658536 100644
--- a/src/components/settings/settings.js
+++ b/src/components/settings/settings.js
@@ -14,7 +14,7 @@ const settings = {
       hideAttachmentsInConvLocal: user.hideAttachmentsInConv,
       hideNsfwLocal: user.hideNsfw,
       hideISPLocal: user.hideISP,
-      preloadNsfwImage: user.preloadNsfwImage,
+      preloadImage: user.preloadImage,
       hidePostStatsLocal: typeof user.hidePostStats === 'undefined'
         ? instance.hidePostStats
         : user.hidePostStats,
@@ -85,8 +85,8 @@ const settings = {
     hideNsfwLocal (value) {
       this.$store.dispatch('setOption', { name: 'hideNsfw', value })
     },
-    preloadNsfwImage(value) {
-      this.$store.dispatch('setOption', { name: 'preloadNsfwImage', value })
+    preloadImage(value) {
+      this.$store.dispatch('setOption', { name: 'preloadImage', value })
     },
     hideISPLocal (value) {
       this.$store.dispatch('setOption', { name: 'hideISP', value })
diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue
index 60b70227..b98d4c1a 100644
--- a/src/components/settings/settings.vue
+++ b/src/components/settings/settings.vue
@@ -118,10 +118,12 @@
               <input type="checkbox" id="hideNsfw" v-model="hideNsfwLocal">
               <label for="hideNsfw">{{$t('settings.nsfw_clickthrough')}}</label>
             </li>
-            <li>
-              <input type="checkbox" id="preloadNsfwImage" v-model="preloadNsfwImage">
-              <label for="preloadNsfwImage">{{$t('settings.preload_sensitive')}}</label>
-            </li>
+            <ul class="setting-list suboptions" >
+              <li>
+                <input type="checkbox" id="preloadImage" v-model="preloadImage">
+                <label for="preloadImage">{{$t('settings.preload_images')}}</label>
+              </li>
+            </ul>
             <li>
               <input type="checkbox" id="stopGifs" v-model="stopGifs">
               <label for="stopGifs">{{$t('settings.stop_gifs')}}</label>
diff --git a/src/i18n/en.json b/src/i18n/en.json
index dc47788c..92429e4b 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -125,7 +125,7 @@
     "hide_attachments_in_convo": "Hide attachments in conversations",
     "hide_attachments_in_tl": "Hide attachments in timeline",
     "hide_isp": "Hide instance-specific panel",
-    "preload_sensitive": "Preload Sensitive Images",
+    "preload_images": "Preload images",
     "hide_post_stats": "Hide post statistics (e.g. the number of favorites)",
     "hide_user_stats": "Hide user statistics (e.g. the number of followers)",
     "import_followers_from_a_csv_file": "Import follows from a csv file",
diff --git a/src/modules/config.js b/src/modules/config.js
index 7b0b2cf4..72839476 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -9,7 +9,7 @@ const defaultState = {
   hideAttachments: false,
   hideAttachmentsInConv: false,
   hideNsfw: true,
-  preloadNsfwImage: true,
+  preloadImage: true,
   loopVideo: true,
   loopVideoSilentOnly: true,
   autoLoad: true,
-- 
cgit v1.2.3-70-g09d2

