mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
steal better solution from @roschaefer commit f0cde51
This commit is contained in:
parent
ba82765fa7
commit
b50f18b340
@ -6,9 +6,9 @@
|
|||||||
<ds-flex class="main-navigation-flex" centered>
|
<ds-flex class="main-navigation-flex" centered>
|
||||||
<ds-flex-item :width="{ lg: '3.5%' }" />
|
<ds-flex-item :width="{ lg: '3.5%' }" />
|
||||||
<ds-flex-item :width="{ base: '80%', sm: '80%', md: '80%', lg: '15%' }">
|
<ds-flex-item :width="{ base: '80%', sm: '80%', md: '80%', lg: '15%' }">
|
||||||
<a @click="redirectToRoot" class="main-navigation-logo">
|
<nuxt-link :to="{ name: 'index' }">
|
||||||
<ds-logo />
|
<ds-logo />
|
||||||
</a>
|
</nuxt-link>
|
||||||
</ds-flex-item>
|
</ds-flex-item>
|
||||||
<ds-flex-item
|
<ds-flex-item
|
||||||
:width="{ base: '20%', sm: '20%', md: '20%', lg: '0%' }"
|
:width="{ base: '20%', sm: '20%', md: '20%', lg: '0%' }"
|
||||||
@ -147,7 +147,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
import { mapGetters, mapActions } from 'vuex'
|
||||||
import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch'
|
import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch'
|
||||||
import SearchInput from '~/components/SearchInput.vue'
|
import SearchInput from '~/components/SearchInput.vue'
|
||||||
import Modal from '~/components/Modal'
|
import Modal from '~/components/Modal'
|
||||||
@ -183,8 +183,6 @@ export default {
|
|||||||
isAdmin: 'auth/isAdmin',
|
isAdmin: 'auth/isAdmin',
|
||||||
quickSearchResults: 'search/quickResults',
|
quickSearchResults: 'search/quickResults',
|
||||||
quickSearchPending: 'search/quickPending',
|
quickSearchPending: 'search/quickPending',
|
||||||
usersFollowedFilter: 'posts/usersFollowedFilter',
|
|
||||||
categoriesFilter: 'posts/categoriesFilter',
|
|
||||||
}),
|
}),
|
||||||
userName() {
|
userName() {
|
||||||
const { name } = this.user || {}
|
const { name } = this.user || {}
|
||||||
@ -236,10 +234,6 @@ export default {
|
|||||||
...mapActions({
|
...mapActions({
|
||||||
quickSearchClear: 'search/quickClear',
|
quickSearchClear: 'search/quickClear',
|
||||||
quickSearch: 'search/quickSearch',
|
quickSearch: 'search/quickSearch',
|
||||||
fetchPosts: 'posts/fetchPosts',
|
|
||||||
}),
|
|
||||||
...mapMutations({
|
|
||||||
setFilteredByFollowers: 'posts/SET_FILTERED_BY_FOLLOWERS',
|
|
||||||
}),
|
}),
|
||||||
goToPost(item) {
|
goToPost(item) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
@ -259,17 +253,6 @@ export default {
|
|||||||
toggleMobileMenuView() {
|
toggleMobileMenuView() {
|
||||||
this.toggleMobileMenu = !this.toggleMobileMenu
|
this.toggleMobileMenu = !this.toggleMobileMenu
|
||||||
},
|
},
|
||||||
redirectToRoot() {
|
|
||||||
this.$router.replace('/')
|
|
||||||
this.fetchPosts({
|
|
||||||
i18n: this.$i18n,
|
|
||||||
filter: {
|
|
||||||
...this.usersFollowedFilter,
|
|
||||||
...this.categoriesFilter,
|
|
||||||
...this.filter,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
Category: {
|
Category: {
|
||||||
@ -310,9 +293,6 @@ export default {
|
|||||||
.main-navigation-right .desktop-view {
|
.main-navigation-right .desktop-view {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
.main-navigation-logo {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.avatar-menu {
|
.avatar-menu {
|
||||||
margin: 2px 0px 0px 5px;
|
margin: 2px 0px 0px 5px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,119 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const state = () => {
|
|
||||||
return {
|
|
||||||
posts: [],
|
|
||||||
filteredByUsersFollowed: false,
|
|
||||||
filteredByCategories: false,
|
|
||||||
usersFollowedFilter: {},
|
|
||||||
categoriesFilter: {},
|
|
||||||
selectedCategoryIds: [],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const mutations = {
|
|
||||||
SET_POSTS(state, posts) {
|
|
||||||
state.posts = posts || null
|
|
||||||
},
|
|
||||||
SET_FILTERED_BY_FOLLOWERS(state, boolean) {
|
|
||||||
state.filteredByUsersFollowed = boolean || null
|
|
||||||
},
|
|
||||||
SET_FILTERED_BY_CATEGORIES(state, boolean) {
|
|
||||||
state.filteredByCategories = boolean || null
|
|
||||||
},
|
|
||||||
SET_USERS_FOLLOWED_FILTER(state, filter) {
|
|
||||||
state.usersFollowedFilter = filter || null
|
|
||||||
},
|
|
||||||
SET_CATEGORIES_FILTER(state, filter) {
|
|
||||||
state.categoriesFilter = filter || null
|
|
||||||
},
|
|
||||||
SET_SELECTED_CATEGORY_IDS(state, categoryId) {
|
|
||||||
if (!categoryId) {
|
|
||||||
state.selectedCategoryIds = []
|
|
||||||
} else {
|
|
||||||
const index = state.selectedCategoryIds.indexOf(categoryId)
|
|
||||||
if (index > -1) {
|
|
||||||
state.selectedCategoryIds.splice(index, 1)
|
|
||||||
} else {
|
|
||||||
state.selectedCategoryIds.push(categoryId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getters = {
|
|
||||||
posts(state) {
|
|
||||||
return state.posts || []
|
|
||||||
},
|
|
||||||
filteredByUsersFollowed(state) {
|
|
||||||
return state.filteredByUsersFollowed || false
|
|
||||||
},
|
|
||||||
filteredByCategories(state) {
|
|
||||||
return state.filteredByCategories || false
|
|
||||||
},
|
|
||||||
usersFollowedFilter(state) {
|
|
||||||
return state.usersFollowedFilter || {}
|
|
||||||
},
|
|
||||||
categoriesFilter(state) {
|
|
||||||
return state.categoriesFilter || {}
|
|
||||||
},
|
|
||||||
selectedCategoryIds(state) {
|
|
||||||
return state.selectedCategoryIds || []
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export const actions = {
|
|
||||||
async fetchPosts({ commit, dispatch }, { i18n, filter }) {
|
|
||||||
const client = this.app.apolloProvider.defaultClient
|
|
||||||
const {
|
|
||||||
data: { Post },
|
|
||||||
} = await client.query({
|
|
||||||
query: gql`
|
|
||||||
query Post($filter: _PostFilter, $first: Int, $offset: Int) {
|
|
||||||
Post(filter: $filter, first: $first, offset: $offset) {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
contentExcerpt
|
|
||||||
createdAt
|
|
||||||
disabled
|
|
||||||
deleted
|
|
||||||
slug
|
|
||||||
image
|
|
||||||
author {
|
|
||||||
id
|
|
||||||
avatar
|
|
||||||
slug
|
|
||||||
name
|
|
||||||
disabled
|
|
||||||
deleted
|
|
||||||
contributionsCount
|
|
||||||
shoutedCount
|
|
||||||
commentedCount
|
|
||||||
followedByCount
|
|
||||||
followedByCurrentUser
|
|
||||||
location {
|
|
||||||
name: name${i18n.locale().toUpperCase()}
|
|
||||||
}
|
|
||||||
badges {
|
|
||||||
id
|
|
||||||
icon
|
|
||||||
}
|
|
||||||
}
|
|
||||||
categories {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
icon
|
|
||||||
}
|
|
||||||
shoutedCount
|
|
||||||
}
|
|
||||||
}`,
|
|
||||||
variables: {
|
|
||||||
filter,
|
|
||||||
first: 12,
|
|
||||||
offset: 0,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
commit('SET_POSTS', Post)
|
|
||||||
return Post
|
|
||||||
},
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user