aboutsummaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'src/services')
-rw-r--r--src/services/api/api.service.js32
-rw-r--r--src/services/backend_interactor_service/backend_interactor_service.js6
-rw-r--r--src/services/entity_normalizer/entity_normalizer.service.js3
-rw-r--r--src/services/notifications_fetcher/notifications_fetcher.service.js12
4 files changed, 52 insertions, 1 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 13d31d91..7b04343d 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -18,6 +18,7 @@ const MENTIONS_URL = '/api/statuses/mentions.json'
const DM_TIMELINE_URL = '/api/statuses/dm_timeline.json'
const FOLLOWERS_URL = '/api/statuses/followers.json'
const FRIENDS_URL = '/api/statuses/friends.json'
+const BLOCKS_URL = '/api/statuses/blocks.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'
@@ -519,6 +520,34 @@ const fetchMutes = ({credentials}) => {
}).then((data) => data.json())
}
+const fetchBlocks = ({page, credentials}) => {
+ return fetch(BLOCKS_URL, {
+ headers: authHeaders(credentials)
+ }).then((data) => {
+ if (data.ok) {
+ return data.json()
+ }
+ throw new Error('Error fetching blocks', data)
+ })
+}
+
+const fetchOAuthTokens = ({credentials}) => {
+ const url = '/api/oauth_tokens.json'
+
+ return fetch(url, {
+ headers: authHeaders(credentials)
+ }).then((data) => data.json())
+}
+
+const revokeOAuthToken = ({id, credentials}) => {
+ const url = `/api/oauth_tokens/${id}`
+
+ return fetch(url, {
+ headers: authHeaders(credentials),
+ method: 'DELETE'
+ })
+}
+
const suggestions = ({credentials}) => {
return fetch(SUGGESTIONS_URL, {
headers: authHeaders(credentials)
@@ -560,6 +589,9 @@ const apiService = {
fetchAllFollowing,
setUserMute,
fetchMutes,
+ fetchBlocks,
+ fetchOAuthTokens,
+ revokeOAuthToken,
register,
getCaptcha,
updateAvatar,
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index 80c5cc5e..2278cd45 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -63,7 +63,10 @@ const backendInteractorService = (credentials) => {
}
const fetchMutes = () => apiService.fetchMutes({credentials})
+ const fetchBlocks = (params) => apiService.fetchBlocks({credentials, ...params})
const fetchFollowRequests = () => apiService.fetchFollowRequests({credentials})
+ const fetchOAuthTokens = () => apiService.fetchOAuthTokens({credentials})
+ const revokeOAuthToken = (id) => apiService.revokeOAuthToken({id, credentials})
const getCaptcha = () => apiService.getCaptcha()
const register = (params) => apiService.register(params)
@@ -94,6 +97,9 @@ const backendInteractorService = (credentials) => {
startFetching,
setUserMute,
fetchMutes,
+ fetchBlocks,
+ fetchOAuthTokens,
+ revokeOAuthToken,
register,
getCaptcha,
updateAvatar,
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js
index 828c48f9..d20ce77f 100644
--- a/src/services/entity_normalizer/entity_normalizer.service.js
+++ b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -117,6 +117,9 @@ export const parseUser = (data) => {
output.statuses_count = data.statuses_count
output.friends = []
output.followers = []
+ if (data.pleroma) {
+ output.follow_request_count = data.pleroma.follow_request_count
+ }
return output
}
diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js
index b69ec643..3ecdae6a 100644
--- a/src/services/notifications_fetcher/notifications_fetcher.service.js
+++ b/src/services/notifications_fetcher/notifications_fetcher.service.js
@@ -16,7 +16,17 @@ const fetchAndUpdate = ({store, credentials, older = false}) => {
args['until'] = timelineData.minId
}
} else {
- args['since'] = timelineData.maxId
+ // load unread notifications repeadedly 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'] = timelineData.maxId
+ } else {
+ args['since'] = Math.min(...unread) - 1
+ if (timelineData.maxId !== Math.max(...unread)) {
+ args['until'] = Math.max(...unread, args['since'] + 20)
+ }
+ }
}
args['timeline'] = 'notifications'