Merge branch 'feature/filtering' into 'develop'
Feature/filtering See merge request !68
This commit is contained in:
commit
7ee87c7618
7 changed files with 64 additions and 18 deletions
|
@ -1,11 +1,13 @@
|
||||||
import StyleSwitcher from '../style_switcher/style_switcher.vue'
|
import StyleSwitcher from '../style_switcher/style_switcher.vue'
|
||||||
|
import { filter, trim } from 'lodash'
|
||||||
|
|
||||||
const settings = {
|
const settings = {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
hideAttachmentsLocal: this.$store.state.config.hideAttachments,
|
hideAttachmentsLocal: this.$store.state.config.hideAttachments,
|
||||||
hideAttachmentsInConvLocal: this.$store.state.config.hideAttachmentsInConv,
|
hideAttachmentsInConvLocal: this.$store.state.config.hideAttachmentsInConv,
|
||||||
hideNsfwLocal: this.$store.state.config.hideNsfw
|
hideNsfwLocal: this.$store.state.config.hideNsfw,
|
||||||
|
muteWordsString: this.$store.state.config.muteWords.join('\n')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -20,6 +22,10 @@ const settings = {
|
||||||
},
|
},
|
||||||
hideNsfwLocal (value) {
|
hideNsfwLocal (value) {
|
||||||
this.$store.dispatch('setOption', { name: 'hideNsfw', value })
|
this.$store.dispatch('setOption', { name: 'hideNsfw', value })
|
||||||
|
},
|
||||||
|
muteWordsString (value) {
|
||||||
|
value = filter(value.split('\n'), (word) => trim(word).length > 0)
|
||||||
|
this.$store.dispatch('setOption', { name: 'muteWords', value })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,11 @@
|
||||||
<h2>Theme</h2>
|
<h2>Theme</h2>
|
||||||
<style-switcher></style-switcher>
|
<style-switcher></style-switcher>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="setting-item">
|
||||||
|
<h2>Filtering</h2>
|
||||||
|
<p>All notices containing these words will be muted, one per line</p>
|
||||||
|
<textarea id="muteWords" v-model="muteWordsString"></textarea>
|
||||||
|
</div>
|
||||||
<div class="setting-item">
|
<div class="setting-item">
|
||||||
<h2>Attachments</h2>
|
<h2>Attachments</h2>
|
||||||
<ul class="setting-list">
|
<ul class="setting-list">
|
||||||
|
@ -32,9 +37,13 @@
|
||||||
<script src="./settings.js">
|
<script src="./settings.js">
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style lang="scss">
|
||||||
.setting-item {
|
.setting-item {
|
||||||
margin: 1em 1em 1.4em;
|
margin: 1em 1em 1.4em;
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.setting-list {
|
.setting-list {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import RetweetButton from '../retweet_button/retweet_button.vue'
|
||||||
import DeleteButton from '../delete_button/delete_button.vue'
|
import DeleteButton from '../delete_button/delete_button.vue'
|
||||||
import PostStatusForm from '../post_status_form/post_status_form.vue'
|
import PostStatusForm from '../post_status_form/post_status_form.vue'
|
||||||
import UserCardContent from '../user_card_content/user_card_content.vue'
|
import UserCardContent from '../user_card_content/user_card_content.vue'
|
||||||
|
import { filter } from 'lodash'
|
||||||
|
|
||||||
const Status = {
|
const Status = {
|
||||||
props: [
|
props: [
|
||||||
|
@ -19,6 +20,9 @@ const Status = {
|
||||||
userExpanded: false
|
userExpanded: false
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
|
muteWords () {
|
||||||
|
return this.$store.state.config.muteWords
|
||||||
|
},
|
||||||
hideAttachments () {
|
hideAttachments () {
|
||||||
return (this.$store.state.config.hideAttachments && !this.inConversation) ||
|
return (this.$store.state.config.hideAttachments && !this.inConversation) ||
|
||||||
(this.$store.state.config.hideAttachmentsInConv && this.inConversation)
|
(this.$store.state.config.hideAttachmentsInConv && this.inConversation)
|
||||||
|
@ -35,7 +39,15 @@ const Status = {
|
||||||
loggedIn () {
|
loggedIn () {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!this.$store.state.users.currentUser
|
||||||
},
|
},
|
||||||
muted () { return !this.unmuted && this.status.user.muted },
|
muteWordHits () {
|
||||||
|
const statusText = this.status.text.toLowerCase()
|
||||||
|
const hits = filter(this.muteWords, (muteWord) => {
|
||||||
|
return statusText.includes(muteWord.toLowerCase())
|
||||||
|
})
|
||||||
|
|
||||||
|
return hits
|
||||||
|
},
|
||||||
|
muted () { return !this.unmuted && (this.status.user.muted || this.muteWordHits.length > 0) },
|
||||||
isReply () { return !!this.status.in_reply_to_status_id },
|
isReply () { return !!this.status.in_reply_to_status_id },
|
||||||
borderColor () {
|
borderColor () {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<template v-if="muted">
|
<template v-if="muted">
|
||||||
<div class="media status container muted">
|
<div class="media status container muted">
|
||||||
<small><router-link :to="{ name: 'user-profile', params: { id: status.user.id } }">{{status.user.screen_name}}</router-link></small>
|
<small><router-link :to="{ name: 'user-profile', params: { id: status.user.id } }">{{status.user.screen_name}}</router-link></small>
|
||||||
|
<small class="muteWords">{{muteWordHits.join(', ')}}</small>
|
||||||
<a href="#" class="unmute" @click.prevent="toggleMute"><i class="icon-eye-off"></i></a>
|
<a href="#" class="unmute" @click.prevent="toggleMute"><i class="icon-eye-off"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -52,10 +53,10 @@
|
||||||
<small>
|
<small>
|
||||||
<a href="#" @click.prevent="toggleExpanded" ><i class="icon-plus-squared"></i></a>
|
<a href="#" @click.prevent="toggleExpanded" ><i class="icon-plus-squared"></i></a>
|
||||||
</small>
|
</small>
|
||||||
<small v-if="status.user.muted">
|
|
||||||
<a href="#" @click.prevent="toggleMute" ><i class="icon-eye-off"></i></a>
|
|
||||||
</small>
|
|
||||||
</template>
|
</template>
|
||||||
|
<small v-if="unmuted">
|
||||||
|
<a href="#" @click.prevent="toggleMute" ><i class="icon-eye-off"></i></a>
|
||||||
|
</small>
|
||||||
<small v-if="!status.is_local" class="source_url">
|
<small v-if="!status.is_local" class="source_url">
|
||||||
<a :href="status.external_url" target="_blank" ><i class="icon-binoculars"></i></a>
|
<a :href="status.external_url" target="_blank" ><i class="icon-binoculars"></i></a>
|
||||||
</small>
|
</small>
|
||||||
|
@ -167,6 +168,10 @@
|
||||||
button {
|
button {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.muteWords {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a.unmute {
|
a.unmute {
|
||||||
|
|
|
@ -3,6 +3,8 @@ import objectPath from 'object-path'
|
||||||
import localforage from 'localforage'
|
import localforage from 'localforage'
|
||||||
import { throttle, each } from 'lodash'
|
import { throttle, each } from 'lodash'
|
||||||
|
|
||||||
|
let loaded = false
|
||||||
|
|
||||||
const defaultReducer = (state, paths) => (
|
const defaultReducer = (state, paths) => (
|
||||||
paths.length === 0 ? state : paths.reduce((substate, path) => {
|
paths.length === 0 ? state : paths.reduce((substate, path) => {
|
||||||
objectPath.set(substate, path, objectPath.get(state, path))
|
objectPath.set(substate, path, objectPath.get(state, path))
|
||||||
|
@ -15,7 +17,11 @@ const defaultStorage = (() => {
|
||||||
})()
|
})()
|
||||||
|
|
||||||
const defaultSetState = (key, state, storage) => {
|
const defaultSetState = (key, state, storage) => {
|
||||||
return storage.setItem(key, state)
|
if (!loaded) {
|
||||||
|
console.log('waiting for old state to be loaded...')
|
||||||
|
} else {
|
||||||
|
return storage.setItem(key, state)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function createPersistedState ({
|
export default function createPersistedState ({
|
||||||
|
@ -32,17 +38,23 @@ export default function createPersistedState ({
|
||||||
} = {}) {
|
} = {}) {
|
||||||
return store => {
|
return store => {
|
||||||
getState(key, storage).then((savedState) => {
|
getState(key, storage).then((savedState) => {
|
||||||
if (typeof savedState === 'object') {
|
try {
|
||||||
// build user cache
|
if (typeof savedState === 'object') {
|
||||||
const usersState = savedState.users || {}
|
// build user cache
|
||||||
usersState.usersObject = {}
|
const usersState = savedState.users || {}
|
||||||
const users = usersState.users || []
|
usersState.usersObject = {}
|
||||||
each(users, (user) => { usersState.usersObject[user.id] = user })
|
const users = usersState.users || []
|
||||||
savedState.users = usersState
|
each(users, (user) => { usersState.usersObject[user.id] = user })
|
||||||
|
savedState.users = usersState
|
||||||
|
|
||||||
store.replaceState(
|
store.replaceState(
|
||||||
merge({}, store.state, savedState)
|
merge({}, store.state, savedState)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
loaded = true
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Couldn't load state")
|
||||||
|
loaded = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ const persistedStateOptions = {
|
||||||
'config.hideAttachments',
|
'config.hideAttachments',
|
||||||
'config.hideAttachmentsInConv',
|
'config.hideAttachmentsInConv',
|
||||||
'config.hideNsfw',
|
'config.hideNsfw',
|
||||||
|
'config.muteWords',
|
||||||
'statuses.notifications',
|
'statuses.notifications',
|
||||||
'users.users'
|
'users.users'
|
||||||
]
|
]
|
||||||
|
|
|
@ -6,7 +6,8 @@ const defaultState = {
|
||||||
colors: {},
|
colors: {},
|
||||||
hideAttachments: false,
|
hideAttachments: false,
|
||||||
hideAttachmentsInConv: false,
|
hideAttachmentsInConv: false,
|
||||||
hideNsfw: true
|
hideNsfw: true,
|
||||||
|
muteWords: []
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
|
Loading…
Reference in a new issue