Merge branch 'develop' into feat/emoji-reactions
This commit is contained in:
commit
c4beac5f89
28 changed files with 365 additions and 82 deletions
|
@ -72,6 +72,7 @@ const MASTODON_MUTE_CONVERSATION = id => `/api/v1/statuses/${id}/mute`
|
|||
const MASTODON_UNMUTE_CONVERSATION = id => `/api/v1/statuses/${id}/unmute`
|
||||
const MASTODON_SEARCH_2 = `/api/v2/search`
|
||||
const MASTODON_USER_SEARCH_URL = '/api/v1/accounts/search'
|
||||
const MASTODON_DOMAIN_BLOCKS_URL = '/api/v1/domain_blocks'
|
||||
const MASTODON_STREAMING = '/api/v1/streaming'
|
||||
const PLEROMA_EMOJI_REACTIONS_URL = id => `/api/v1/pleroma/statuses/${id}/emoji_reactions_by`
|
||||
const PLEROMA_EMOJI_REACT_URL = id => `/api/v1/pleroma/statuses/${id}/react_with_emoji`
|
||||
|
@ -973,6 +974,28 @@ const search2 = ({ credentials, q, resolve, limit, offset, following }) => {
|
|||
})
|
||||
}
|
||||
|
||||
const fetchDomainMutes = ({ credentials }) => {
|
||||
return promisedRequest({ url: MASTODON_DOMAIN_BLOCKS_URL, credentials })
|
||||
}
|
||||
|
||||
const muteDomain = ({ domain, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_DOMAIN_BLOCKS_URL,
|
||||
method: 'POST',
|
||||
payload: { domain },
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
const unmuteDomain = ({ domain, credentials }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_DOMAIN_BLOCKS_URL,
|
||||
method: 'DELETE',
|
||||
payload: { domain },
|
||||
credentials
|
||||
})
|
||||
}
|
||||
|
||||
export const getMastodonSocketURI = ({ credentials, stream, args = {} }) => {
|
||||
return Object.entries({
|
||||
...(credentials
|
||||
|
@ -1138,7 +1161,10 @@ const apiService = {
|
|||
reportUser,
|
||||
updateNotificationSettings,
|
||||
search2,
|
||||
searchUsers
|
||||
searchUsers,
|
||||
fetchDomainMutes,
|
||||
muteDomain,
|
||||
unmuteDomain
|
||||
}
|
||||
|
||||
export default apiService
|
||||
|
|
|
@ -16,7 +16,7 @@ const backendInteractorService = credentials => ({
|
|||
return notificationsFetcher.fetchAndUpdate({ store, credentials })
|
||||
},
|
||||
|
||||
startFetchingFollowRequest ({ store }) {
|
||||
startFetchingFollowRequests ({ store }) {
|
||||
return followRequestFetcher.startFetching({ store, credentials })
|
||||
},
|
||||
|
||||
|
|
|
@ -32,12 +32,18 @@ export class RegistrationError extends Error {
|
|||
}
|
||||
|
||||
if (typeof error === 'object') {
|
||||
const errorContents = JSON.parse(error.error)
|
||||
// keys will have the property that has the error, for example 'ap_id',
|
||||
// 'email' or 'captcha', the value will be an array of its error
|
||||
// like "ap_id": ["has been taken"] or "captcha": ["Invalid CAPTCHA"]
|
||||
|
||||
// replace ap_id with username
|
||||
if (error.ap_id) {
|
||||
error.username = error.ap_id
|
||||
delete error.ap_id
|
||||
if (errorContents.ap_id) {
|
||||
errorContents.username = errorContents.ap_id
|
||||
delete errorContents.ap_id
|
||||
}
|
||||
this.message = humanizeErrors(error)
|
||||
|
||||
this.message = humanizeErrors(errorContents)
|
||||
} else {
|
||||
this.message = error
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ const sortById = (a, b) => {
|
|||
}
|
||||
}
|
||||
|
||||
export const visibleNotificationsFromStore = (store, types) => {
|
||||
export const filteredNotificationsFromStore = (store, types) => {
|
||||
// map is just to clone the array since sort mutates it and it causes some issues
|
||||
let sortedNotifications = notificationsFromStore(store).map(_ => _).sort(sortById)
|
||||
sortedNotifications = sortBy(sortedNotifications, 'seen')
|
||||
|
@ -36,4 +36,4 @@ export const visibleNotificationsFromStore = (store, types) => {
|
|||
}
|
||||
|
||||
export const unseenNotificationsFromStore = store =>
|
||||
filter(visibleNotificationsFromStore(store), ({ seen }) => !seen)
|
||||
filter(filteredNotificationsFromStore(store), ({ seen }) => !seen)
|
||||
|
|
|
@ -2,7 +2,6 @@ import apiService from '../api/api.service.js'
|
|||
|
||||
const update = ({ store, notifications, older }) => {
|
||||
store.dispatch('setNotificationsError', { value: false })
|
||||
|
||||
store.dispatch('addNewNotifications', { notifications, older })
|
||||
}
|
||||
|
||||
|
@ -30,9 +29,9 @@ const fetchAndUpdate = ({ store, credentials, older = false }) => {
|
|||
|
||||
// load unread notifications repeatedly to provide consistency between browser tabs
|
||||
const notifications = timelineData.data
|
||||
const unread = notifications.filter(n => !n.seen).map(n => n.id)
|
||||
if (unread.length) {
|
||||
args['since'] = Math.min(...unread)
|
||||
const readNotifsIds = notifications.filter(n => n.seen).map(n => n.id)
|
||||
if (readNotifsIds.length) {
|
||||
args['since'] = Math.max(...readNotifsIds)
|
||||
fetchNotifications({ store, args, older })
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue