Add option to hide all attachments

This commit is contained in:
ffwff 2019-02-18 20:16:19 +07:00
parent ed4bdf2f13
commit 23d90cf665
8 changed files with 38 additions and 8 deletions

View File

@ -24,7 +24,8 @@ const state = () => {
language: Language.en.key,
defaultFonts: DefaultFonts,
ignoreCW: false,
ignoreNFSW: false
ignoreNFSW: false,
hideAllAttachments: false
}
}

View File

@ -12,7 +12,8 @@ const state = () => {
},
timeline: {
cw: false,
nfsw: false
nfsw: false,
hideAllAttachments: false
}
},
loading: false
@ -88,10 +89,12 @@ describe('Preferences/General', () => {
it('should be updated', async () => {
await store.dispatch('Preferences/updateTimeline', {
cw: true,
nfsw: true
nfsw: true,
hideAllAttachments: true
})
expect(store.state.Preferences.general.timeline.cw).toEqual(true)
expect(store.state.Preferences.general.timeline.nfsw).toEqual(true)
expect(store.state.Preferences.general.timeline.hideAllAttachments).toEqual(true)
expect(store.state.Preferences.loading).toEqual(false)
})
})

View File

@ -121,7 +121,8 @@
"title": "Timeline",
"description": "Customize view in your timelines.",
"cw": "Always ignore contents warnings",
"nfsw": "Always ignore NFSW of medias"
"nfsw": "Always ignore NFSW of medias",
"hideAllAttachments": "Hide all medias"
}
},
"appearance": {

View File

@ -15,7 +15,8 @@ const Base = {
},
timeline: {
cw: false,
nfsw: false
nfsw: false,
hideAllAttachments: false
}
},
state: {

View File

@ -36,6 +36,13 @@
active-color="#13ce66">
</el-switch>
</el-form-item>
<el-form-item for="hideAllAttachments" :label="$t('preferences.general.timeline.hideAllAttachments')">
<el-switch
id="hideAllAttachments"
v-model="timeline_hide_attachments"
active-color="#13ce66">
</el-switch>
</el-form-item>
</el-form>
</div>
</template>
@ -88,6 +95,16 @@ export default {
nfsw: value
})
}
},
timeline_hide_attachments: {
get () {
return this.$store.state.Preferences.General.general.timeline.hideAllAttachments
},
set (value) {
this.$store.dispatch('Preferences/General/updateTimeline', {
hideAllAttachments: value
})
}
}
},
created () {

View File

@ -158,6 +158,7 @@ export default {
return {
showContent: this.$store.state.App.ignoreCW,
showAttachments: this.$store.state.App.ignoreNFSW,
hideAllAttachments: this.$store.state.App.hideAllAttachments,
now: Date.now()
}
},
@ -239,7 +240,7 @@ export default {
return !this.spoilered || this.showContent
},
sensitive: function () {
return this.originalMessage.sensitive && this.mediaAttachments.length > 0
return (this.hideAllAttachments || this.originalMessage.sensitive) && this.mediaAttachments.length > 0
},
isShowAttachments: function () {
return !this.sensitive || this.showAttachments

View File

@ -23,7 +23,8 @@ const App = {
language: Language.en.key,
defaultFonts: DefaultFonts,
ignoreCW: false,
ignoreNFSW: false
ignoreNFSW: false,
hideAllAttachments: false
},
mutations: {
updateTheme (state, themeColorList) {
@ -53,6 +54,9 @@ const App = {
},
updateIgnoreNFSW (state, nfsw) {
state.ignoreNFSW = nfsw
},
updateHideAllAttachments (state, hideAllAttachments) {
state.hideAllAttachments = hideAllAttachments
}
},
actions: {
@ -82,6 +86,7 @@ const App = {
commit('addFont', conf.appearance.font)
commit('updateIgnoreCW', conf.general.timeline.cw)
commit('updateIgnoreNFSW', conf.general.timeline.nfsw)
commit('updateHideAllAttachments', conf.general.timeline.hideAllAttachments)
resolve(conf)
})
})

View File

@ -10,7 +10,8 @@ const General = {
},
timeline: {
cw: false,
nfsw: false
nfsw: false,
hideAllAttachments: false
}
},
loading: false