From b195ce12e1fcf28ea1e74a1231f9a31dcf71af0b Mon Sep 17 00:00:00 2001 From: ValD Date: Wed, 12 Dec 2018 02:28:36 +0530 Subject: [PATCH 1/7] preload nsfw image --- src/components/attachment/attachment.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 40e2cf1b4c..6c8a04edcf 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -10,7 +10,7 @@ Hide - + @@ -161,6 +161,10 @@ display: flex; flex: 1; + &.hidden { + display: none; + } + .still-image { width: 100%; height: 100%; From 7b4e08dd93520e3dc1113d76e097b998d12b0f3c Mon Sep 17 00:00:00 2001 From: ValD Date: Wed, 12 Dec 2018 03:33:53 +0530 Subject: [PATCH 2/7] 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(-) diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 4173072078..71ef2ca4d5 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 6c8a04edcf..1b1956e09b 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -9,8 +9,7 @@ - - + diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 19bd2e5bd0..4d8744dad5 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 dec335059e..60b7022713 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -118,6 +118,10 @@ +
  • + + +
  • diff --git a/src/i18n/en.json b/src/i18n/en.json index 97dfcb7764..dc47788c92 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 45ac8f650a..7b0b2cf4fe 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, From 139659d42ca0a877843a4fa1606435dd6f6442db Mon Sep 17 00:00:00 2001 From: ValD Date: Wed, 12 Dec 2018 03:42:29 +0530 Subject: [PATCH 3/7] 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(-) diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 71ef2ca4d5..fd9a2057d7 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 1b1956e09b..5eaa0d1dfe 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -9,7 +9,7 @@ - + diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 4d8744dad5..9a658536a8 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 60b7022713..b98d4c1ad4 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -118,10 +118,12 @@
  • -
  • - - -
  • +
  • diff --git a/src/i18n/en.json b/src/i18n/en.json index dc47788c92..92429e4b15 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 7b0b2cf4fe..72839476c2 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, From de5d846ebd1243be41be88b1a213888b838af880 Mon Sep 17 00:00:00 2001 From: ValD Date: Wed, 12 Dec 2018 03:44:45 +0530 Subject: [PATCH 4/7] resolved lint issue --- src/components/settings/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 9a658536a8..c9e12708b1 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -85,7 +85,7 @@ const settings = { hideNsfwLocal (value) { this.$store.dispatch('setOption', { name: 'hideNsfw', value }) }, - preloadImage(value) { + preloadImage (value) { this.$store.dispatch('setOption', { name: 'preloadImage', value }) }, hideISPLocal (value) { From 6d3bd95bfeac38a9a1246e30cede3788e8f1e137 Mon Sep 17 00:00:00 2001 From: ValD Date: Wed, 12 Dec 2018 15:07:07 +0000 Subject: [PATCH 5/7] removed brackets from condition --- src/components/attachment/attachment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index fd9a2057d7..574439e093 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -28,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' From 7c6c2cfb22d3fb681ed85ed9ab1d71e11f2a02f9 Mon Sep 17 00:00:00 2001 From: ValD Date: Wed, 12 Dec 2018 23:29:13 +0530 Subject: [PATCH 6/7] added PR comments --- src/components/settings/settings.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue index b98d4c1ad4..6cdc82da1c 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -120,7 +120,7 @@
  • From b271957b4cbee7a489acccbdc84f19d3d6414412 Mon Sep 17 00:00:00 2001 From: ValD Date: Thu, 13 Dec 2018 00:11:01 +0530 Subject: [PATCH 7/7] added not preload check so hidden toggles asap --- src/components/attachment/attachment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 574439e093..16114c30c4 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -47,7 +47,7 @@ const Attachment = { } }, toggleHidden () { - if (this.img) { + if (this.img && !this.preloadImage) { if (this.img.onload) { this.img.onload() } else {