forked from AkkomaGang/akkoma-fe
Grab mutes from server on patched servers.
This commit is contained in:
parent
3fd0d0d1cb
commit
9c1093b6ca
4 changed files with 45 additions and 3 deletions
|
@ -82,6 +82,7 @@
|
||||||
toggleMute () {
|
toggleMute () {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
store.commit('setMuted', {user: this.user, muted: !this.user.muted})
|
store.commit('setMuted', {user: this.user, muted: !this.user.muted})
|
||||||
|
store.state.api.backendInteractor.setUserMute(this.user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,12 @@ const users = {
|
||||||
// Start getting fresh tweets.
|
// Start getting fresh tweets.
|
||||||
store.dispatch('startFetching', 'friends')
|
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
|
// Fetch our friends
|
||||||
store.rootState.api.backendInteractor.fetchFriends()
|
store.rootState.api.backendInteractor.fetchFriends()
|
||||||
.then((friends) => commit('addNewUsers', friends))
|
.then((friends) => commit('addNewUsers', friends))
|
||||||
|
|
|
@ -16,6 +16,7 @@ const MENTIONS_URL = '/api/statuses/mentions.json'
|
||||||
const FRIENDS_URL = '/api/statuses/friends.json'
|
const FRIENDS_URL = '/api/statuses/friends.json'
|
||||||
const FOLLOWING_URL = '/api/friendships/create.json'
|
const FOLLOWING_URL = '/api/friendships/create.json'
|
||||||
const UNFOLLOWING_URL = '/api/friendships/destroy.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 USER_URL = '/api/users/show.json'
|
||||||
|
|
||||||
const oldfetch = window.fetch
|
const oldfetch = window.fetch
|
||||||
|
@ -58,7 +59,7 @@ const fetchFriends = ({credentials}) => {
|
||||||
const fetchAllFollowing = ({username, credentials}) => {
|
const fetchAllFollowing = ({username, credentials}) => {
|
||||||
const url = `${ALL_FOLLOWING_URL}/${username}.json`
|
const url = `${ALL_FOLLOWING_URL}/${username}.json`
|
||||||
return fetch(url, { headers: authHeaders(credentials) })
|
return fetch(url, { headers: authHeaders(credentials) })
|
||||||
.then((data) => data.json().users)
|
.then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchMentions = ({username, sinceId = 0, credentials}) => {
|
const fetchMentions = ({username, sinceId = 0, credentials}) => {
|
||||||
|
@ -79,6 +80,22 @@ const fetchStatus = ({id, credentials}) => {
|
||||||
.then((data) => data.json())
|
.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 fetchTimeline = ({timeline, credentials, since = false, until = false}) => {
|
||||||
const timelineUrls = {
|
const timelineUrls = {
|
||||||
public: PUBLIC_TIMELINE_URL,
|
public: PUBLIC_TIMELINE_URL,
|
||||||
|
@ -162,6 +179,14 @@ const uploadMedia = ({formData, credentials}) => {
|
||||||
.then((text) => (new DOMParser()).parseFromString(text, 'application/xml'))
|
.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 = {
|
const apiService = {
|
||||||
verifyCredentials,
|
verifyCredentials,
|
||||||
fetchTimeline,
|
fetchTimeline,
|
||||||
|
@ -177,7 +202,9 @@ const apiService = {
|
||||||
postStatus,
|
postStatus,
|
||||||
deleteStatus,
|
deleteStatus,
|
||||||
uploadMedia,
|
uploadMedia,
|
||||||
fetchAllFollowing
|
fetchAllFollowing,
|
||||||
|
setUserMute,
|
||||||
|
fetchMutes
|
||||||
}
|
}
|
||||||
|
|
||||||
export default apiService
|
export default apiService
|
||||||
|
|
|
@ -34,6 +34,12 @@ const backendInteractorService = (credentials) => {
|
||||||
return timelineFetcherService.startFetching({timeline, store, 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 = {
|
const backendInteractorServiceInstance = {
|
||||||
fetchStatus,
|
fetchStatus,
|
||||||
fetchConversation,
|
fetchConversation,
|
||||||
|
@ -43,7 +49,9 @@ const backendInteractorService = (credentials) => {
|
||||||
unfollowUser,
|
unfollowUser,
|
||||||
fetchAllFollowing,
|
fetchAllFollowing,
|
||||||
verifyCredentials: apiService.verifyCredentials,
|
verifyCredentials: apiService.verifyCredentials,
|
||||||
startFetching
|
startFetching,
|
||||||
|
setUserMute,
|
||||||
|
fetchMutes
|
||||||
}
|
}
|
||||||
|
|
||||||
return backendInteractorServiceInstance
|
return backendInteractorServiceInstance
|
||||||
|
|
Loading…
Reference in a new issue