Add hashtag following button (#244)
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk> Reviewed-on: https://akkoma.dev/AkkomaGang/pleroma-fe/pulls/244
This commit is contained in:
parent
105ecd3836
commit
eb49295422
6 changed files with 126 additions and 5 deletions
37
src/modules/tags.js
Normal file
37
src/modules/tags.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { merge } from 'lodash'
|
||||
|
||||
const tags = {
|
||||
state: {
|
||||
// Contains key = id, value = number of trackers for this poll
|
||||
tags: {}
|
||||
},
|
||||
mutations: {
|
||||
setTag (state, { name, data }) {
|
||||
state.tags[name] = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
getTag ({ rootState, commit }, tagName) {
|
||||
return rootState.api.backendInteractor.getHashtag({ tag: tagName }).then(tag => {
|
||||
commit('setTag', { name: tagName, data: tag })
|
||||
return tag
|
||||
})
|
||||
},
|
||||
followTag (store, tagName) {
|
||||
return store.rootState.api.backendInteractor.followHashtag({ tag: tagName })
|
||||
.then((resp) => {
|
||||
store.commit('setTag', { name: tagName, data: resp })
|
||||
return resp
|
||||
})
|
||||
},
|
||||
unfollowTag ({ rootState, commit }, tag) {
|
||||
return rootState.api.backendInteractor.unfollowHashtag({ tag })
|
||||
.then((resp) => {
|
||||
commit('setTag', { name: tag, data: resp })
|
||||
return resp
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default tags
|
Loading…
Add table
Add a link
Reference in a new issue