added config for preload and made attachment responsive to it

This commit is contained in:
ValD 2018-12-12 03:33:53 +05:30
parent b195ce12e1
commit 7b4e08dd93
6 changed files with 13 additions and 3 deletions

View File

@ -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'

View File

@ -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>

View File

@ -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 })
},

View File

@ -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>

View File

@ -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",

View File

@ -9,6 +9,7 @@ const defaultState = {
hideAttachments: false,
hideAttachmentsInConv: false,
hideNsfw: true,
preloadNsfwImage: true,
loopVideo: true,
loopVideoSilentOnly: true,
autoLoad: true,