mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
* feat(backend): pin more than one post * add postPinnedCount query, better names for env variable * add store and mixin for pinned posts counts * test pinned post store * context menu for pin posts * fix typos * unpin posts is always possible --------- Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com>
44 lines
1005 B
JavaScript
44 lines
1005 B
JavaScript
import { postsPinnedCountsQuery } from '~/graphql/PostQuery'
|
|
|
|
export const state = () => {
|
|
return {
|
|
maxPinnedPosts: 0,
|
|
currentlyPinnedPosts: 0,
|
|
}
|
|
}
|
|
|
|
export const mutations = {
|
|
pinPost(state) {
|
|
state.currentlyPinnedPosts++
|
|
},
|
|
unpinPost(state) {
|
|
state.currentlyPinnedPosts--
|
|
},
|
|
setMaxPinnedPosts(state, value) {
|
|
state.maxPinnedPosts = value
|
|
},
|
|
setCurrentlyPinnedPosts(state, value) {
|
|
state.currentlyPinnedPosts = value
|
|
},
|
|
}
|
|
|
|
export const getters = {
|
|
maxPinnedPosts(state) {
|
|
return state.maxPinnedPosts
|
|
},
|
|
currentlyPinnedPosts(state) {
|
|
return state.currentlyPinnedPosts
|
|
},
|
|
}
|
|
|
|
export const actions = {
|
|
async fetch({ commit }) {
|
|
const client = this.app.apolloProvider.defaultClient
|
|
const {
|
|
data: { PostsPinnedCounts },
|
|
} = await client.query({ query: postsPinnedCountsQuery() })
|
|
commit('setMaxPinnedPosts', PostsPinnedCounts.maxPinnedPosts)
|
|
commit('setCurrentlyPinnedPosts', PostsPinnedCounts.currentlyPinnedPosts)
|
|
},
|
|
}
|