mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
set category filter as stored in db after login
This commit is contained in:
parent
a65e306b85
commit
b323d0f580
@ -58,6 +58,7 @@ import PageParamsLink from '~/components/_new/features/PageParamsLink/PageParams
|
||||
import LocaleSwitch from '~/components/LocaleSwitch/LocaleSwitch'
|
||||
import Logo from '~/components/Logo/Logo'
|
||||
import ShowPassword from '../ShowPassword/ShowPassword.vue'
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -84,12 +85,28 @@ export default {
|
||||
iconName() {
|
||||
return this.showPassword ? 'eye-slash' : 'eye'
|
||||
},
|
||||
...mapGetters({
|
||||
currentUser: 'auth/user',
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
toggleCategory: 'posts/TOGGLE_CATEGORY',
|
||||
resetCategories: 'posts/RESET_CATEGORIES',
|
||||
}),
|
||||
async onSubmit() {
|
||||
const { email, password } = this.form
|
||||
try {
|
||||
await this.$store.dispatch('auth/login', { email, password })
|
||||
if (this.currentUser && this.currentUser.activeCategories) {
|
||||
if (this.currentUser.activeCategories.length > 0) {
|
||||
this.currentUser.activeCategories.forEach((categoryId) => {
|
||||
this.toggleCategory(categoryId)
|
||||
})
|
||||
} else {
|
||||
this.resetCategories()
|
||||
}
|
||||
}
|
||||
this.$toast.success(this.$t('login.success'))
|
||||
this.$emit('success')
|
||||
} catch (err) {
|
||||
|
||||
@ -3,7 +3,6 @@ import { VERSION } from '~/constants/terms-and-conditions-version.js'
|
||||
import { currentUserQuery } from '~/graphql/User'
|
||||
import Cookie from 'universal-cookie'
|
||||
import metadata from '~/constants/metadata'
|
||||
import { mutations as postMutations } from './posts.js'
|
||||
|
||||
const cookies = new Cookie()
|
||||
|
||||
@ -17,9 +16,6 @@ export const state = () => {
|
||||
|
||||
export const mutations = {
|
||||
SET_USER(state, user) {
|
||||
if (user.activeCategories) {
|
||||
console.log(user.activeCategories)
|
||||
}
|
||||
state.user = user || null
|
||||
},
|
||||
SET_TOKEN(state, token) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user