forked from AkkomaGang/akkoma-fe
Merge branch 'feature/mutes' into develop
This commit is contained in:
commit
9763009d86
5 changed files with 50 additions and 8 deletions
|
@ -82,6 +82,7 @@
|
|||
toggleMute () {
|
||||
const store = this.$store
|
||||
store.commit('setMuted', {user: this.user, muted: !this.user.muted})
|
||||
store.state.api.backendInteractor.setUserMute(this.user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
src/main.js
10
src/main.js
|
@ -17,7 +17,7 @@ import configModule from './modules/config.js'
|
|||
|
||||
import VueTimeago from 'vue-timeago'
|
||||
|
||||
// import createPersistedState from 'vuex-persistedstate'
|
||||
import createPersistedState from 'vuex-persistedstate'
|
||||
|
||||
Vue.use(Vuex)
|
||||
Vue.use(VueRouter)
|
||||
|
@ -28,9 +28,9 @@ Vue.use(VueTimeago, {
|
|||
}
|
||||
})
|
||||
|
||||
// const persistedStateOptions = {
|
||||
// paths: ['users.users', 'statuses.notifications']
|
||||
// }
|
||||
const persistedStateOptions = {
|
||||
paths: ['users.users']
|
||||
}
|
||||
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
|
@ -39,7 +39,7 @@ const store = new Vuex.Store({
|
|||
api: apiModule,
|
||||
config: configModule
|
||||
},
|
||||
// plugins: [createPersistedState(persistedStateOptions)],
|
||||
plugins: [createPersistedState(persistedStateOptions)],
|
||||
strict: process.env.NODE_ENV !== 'production'
|
||||
})
|
||||
|
||||
|
|
|
@ -82,6 +82,12 @@ const users = {
|
|||
// Start getting fresh tweets.
|
||||
store.dispatch('startFetching', 'friends')
|
||||
|
||||
// Get user mutes and follower info
|
||||
store.rootState.api.backendInteractor.fetchMutes().then((mutedUsers) => {
|
||||
each(mutedUsers, (user) => { user.muted = true })
|
||||
store.commit('addNewUsers', mutedUsers)
|
||||
})
|
||||
|
||||
// Fetch our friends
|
||||
store.rootState.api.backendInteractor.fetchFriends()
|
||||
.then((friends) => commit('addNewUsers', friends))
|
||||
|
|
|
@ -16,6 +16,7 @@ const MENTIONS_URL = '/api/statuses/mentions.json'
|
|||
const FRIENDS_URL = '/api/statuses/friends.json'
|
||||
const FOLLOWING_URL = '/api/friendships/create.json'
|
||||
const UNFOLLOWING_URL = '/api/friendships/destroy.json'
|
||||
const QVITTER_USER_PREF_URL = '/api/qvitter/set_profile_pref.json'
|
||||
// const USER_URL = '/api/users/show.json'
|
||||
|
||||
const oldfetch = window.fetch
|
||||
|
@ -58,7 +59,7 @@ const fetchFriends = ({credentials}) => {
|
|||
const fetchAllFollowing = ({username, credentials}) => {
|
||||
const url = `${ALL_FOLLOWING_URL}/${username}.json`
|
||||
return fetch(url, { headers: authHeaders(credentials) })
|
||||
.then((data) => data.json().users)
|
||||
.then((data) => data.json())
|
||||
}
|
||||
|
||||
const fetchMentions = ({username, sinceId = 0, credentials}) => {
|
||||
|
@ -79,6 +80,22 @@ const fetchStatus = ({id, credentials}) => {
|
|||
.then((data) => data.json())
|
||||
}
|
||||
|
||||
const setUserMute = ({id, credentials, muted = true}) => {
|
||||
const form = new FormData()
|
||||
|
||||
const muteInteger = muted ? 1 : 0
|
||||
|
||||
form.append('namespace', 'qvitter')
|
||||
form.append('data', muteInteger)
|
||||
form.append('topic', `mute:${id}`)
|
||||
|
||||
return fetch(QVITTER_USER_PREF_URL, {
|
||||
method: 'POST',
|
||||
headers: authHeaders(credentials),
|
||||
body: form
|
||||
})
|
||||
}
|
||||
|
||||
const fetchTimeline = ({timeline, credentials, since = false, until = false}) => {
|
||||
const timelineUrls = {
|
||||
public: PUBLIC_TIMELINE_URL,
|
||||
|
@ -162,6 +179,14 @@ const uploadMedia = ({formData, credentials}) => {
|
|||
.then((text) => (new DOMParser()).parseFromString(text, 'application/xml'))
|
||||
}
|
||||
|
||||
const fetchMutes = ({credentials}) => {
|
||||
const url = '/api/qvitter/mutes.json'
|
||||
|
||||
return fetch(url, {
|
||||
headers: authHeaders(credentials)
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const apiService = {
|
||||
verifyCredentials,
|
||||
fetchTimeline,
|
||||
|
@ -177,7 +202,9 @@ const apiService = {
|
|||
postStatus,
|
||||
deleteStatus,
|
||||
uploadMedia,
|
||||
fetchAllFollowing
|
||||
fetchAllFollowing,
|
||||
setUserMute,
|
||||
fetchMutes
|
||||
}
|
||||
|
||||
export default apiService
|
||||
|
|
|
@ -34,6 +34,12 @@ const backendInteractorService = (credentials) => {
|
|||
return timelineFetcherService.startFetching({timeline, store, credentials})
|
||||
}
|
||||
|
||||
const setUserMute = ({id, muted = true}) => {
|
||||
return apiService.setUserMute({id, muted, credentials})
|
||||
}
|
||||
|
||||
const fetchMutes = () => apiService.fetchMutes({credentials})
|
||||
|
||||
const backendInteractorServiceInstance = {
|
||||
fetchStatus,
|
||||
fetchConversation,
|
||||
|
@ -43,7 +49,9 @@ const backendInteractorService = (credentials) => {
|
|||
unfollowUser,
|
||||
fetchAllFollowing,
|
||||
verifyCredentials: apiService.verifyCredentials,
|
||||
startFetching
|
||||
startFetching,
|
||||
setUserMute,
|
||||
fetchMutes
|
||||
}
|
||||
|
||||
return backendInteractorServiceInstance
|
||||
|
|
Loading…
Reference in a new issue