Don't chane the filterPostsMenu with state

@mattwr18 state is the root of all evil
This commit is contained in:
Robert Schäfer 2019-08-09 17:10:43 +02:00
parent cea206d118
commit a8cfe96f60
4 changed files with 4 additions and 27 deletions

View File

@ -183,7 +183,6 @@ export default {
isAdmin: 'auth/isAdmin',
quickSearchResults: 'search/quickResults',
quickSearchPending: 'search/quickPending',
showFilterPostsDropdown: 'default/showFilterPostsDropdown',
usersFollowedFilter: 'posts/usersFollowedFilter',
categoriesFilter: 'posts/categoriesFilter',
}),
@ -223,6 +222,10 @@ export default {
}
return routes
},
showFilterPostsDropdown() {
const [firstRoute] = this.$route.matched
return firstRoute.name === 'index'
},
},
watch: {
Category(category) {

View File

@ -5,7 +5,6 @@ import Styleguide from '@human-connection/styleguide'
import Filters from '~/plugins/vue-filters'
import VTooltip from 'v-tooltip'
import FilterMenu from '~/components/FilterMenu/FilterMenu'
import { mutations } from '~/store/default'
const localVue = createLocalVue()
@ -44,9 +43,6 @@ describe('PostIndex', () => {
'posts/usersFollowedFilter': () => {},
'posts/categoriesFilter': () => {},
},
mutations: {
'default/SET_SHOW_FILTER_POSTS_DROPDOWN': mutations.SET_SHOW_FILTER_POSTS_DROPDOWN,
},
})
mocks = {
$t: key => key,

View File

@ -92,14 +92,10 @@ export default {
}
},
mounted() {
this.toggleShowFilterPostsDropdown(true)
if (this.hashtag) {
this.changeFilterBubble({ tags_some: { name: this.hashtag } })
}
},
beforeDestroy() {
this.toggleShowFilterPostsDropdown(false)
},
watch: {
Post(post) {
this.setPosts(this.Post)
@ -122,7 +118,6 @@ export default {
methods: {
...mapMutations({
setPosts: 'posts/SET_POSTS',
toggleShowFilterPostsDropdown: 'default/SET_SHOW_FILTER_POSTS_DROPDOWN',
}),
changeFilterBubble(filter) {
if (this.hashtag) {

View File

@ -1,17 +0,0 @@
export const state = () => {
return {
showFilterPostsDropdown: false,
}
}
export const getters = {
showFilterPostsDropdown(state) {
return state.showFilterPostsDropdown || false
},
}
export const mutations = {
SET_SHOW_FILTER_POSTS_DROPDOWN(state, boolean) {
state.showFilterPostsDropdown = boolean || null
},
}