aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordave <starpumadev@gmail.com>2019-03-18 12:30:34 -0400
committerdave <starpumadev@gmail.com>2019-03-18 12:30:34 -0400
commit060d3b0713307dc247a2bf4b0d4bc957ffab97f6 (patch)
treef9a2803faaacf34c286f19c2c3866c0eaac8df34 /src
parent55d7bd6d4eccb4d8cfdad4a9e431995b2db3d461 (diff)
#436: implement is_seen logic
Diffstat (limited to 'src')
-rw-r--r--src/services/entity_normalizer/entity_normalizer.service.js2
-rw-r--r--src/services/notifications_fetcher/notifications_fetcher.service.js32
2 files changed, 18 insertions, 16 deletions
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js
index 06f7e938..36a9508a 100644
--- a/src/services/entity_normalizer/entity_normalizer.service.js
+++ b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -280,7 +280,7 @@ export const parseNotification = (data) => {
if (masto) {
output.type = mastoDict[data.type] || data.type
- // output.seen = ??? missing
+ output.seen = data.pleroma.is_seen
output.status = output.type === 'follow'
? parseFollow(data)
: parseStatus(data.status)
diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js
index 9eac5ab4..60c497ae 100644
--- a/src/services/notifications_fetcher/notifications_fetcher.service.js
+++ b/src/services/notifications_fetcher/notifications_fetcher.service.js
@@ -11,33 +11,35 @@ const fetchAndUpdate = ({store, credentials, older = false}) => {
const rootState = store.rootState || store.state
const timelineData = rootState.statuses.notifications
+ args['timeline'] = 'notifications'
if (older) {
if (timelineData.minId !== Number.POSITIVE_INFINITY) {
args['until'] = timelineData.minId
}
+ return fetchNotifications({ store, args, older })
} else {
+ // fetch new notifications
if (timelineData.maxId !== Number.POSITIVE_INFINITY) {
args['since'] = timelineData.maxId
}
- // # disabled until is_seen is impelented on the BE
- // 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)
- // }
- // }
- }
+ const result = fetchNotifications({ store, args, older })
+
+ // 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)
+ fetchNotifications({ store, args, older })
+ }
- args['timeline'] = 'notifications'
+ return result
+ }
+}
+const fetchNotifications = ({ store, args, older }) => {
return apiService.fetchTimeline(args)
.then((notifications) => {
- update({store, notifications, older})
+ update({ store, notifications, older })
return notifications
}, () => store.dispatch('setNotificationsError', { value: true }))
.catch(() => store.dispatch('setNotificationsError', { value: true }))