Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
pleroma-fe
Commits
3ebd4e44
Commit
3ebd4e44
authored
4 years ago
by
Shpuld Shpludson
Browse files
Options
Downloads
Patches
Plain Diff
document the 'mark-as-read-detection' system
parent
a3e370e9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1217
2.1.0 into master
,
!1164
Fix: notifications fetcher double fetching on every tick
Pipeline
#27935
passed
4 years ago
Stage: lint
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/services/notifications_fetcher/notifications_fetcher.service.js
+9
-8
9 additions, 8 deletions
...es/notifications_fetcher/notifications_fetcher.service.js
with
9 additions
and
8 deletions
src/services/notifications_fetcher/notifications_fetcher.service.js
+
9
−
8
View file @
3ebd4e44
...
...
@@ -27,17 +27,18 @@ const fetchAndUpdate = ({ store, credentials, older = false }) => {
}
const
result
=
fetchNotifications
({
store
,
args
,
older
})
// load unread notifications repeatedly to provide consistency between browser tabs
// If there's any unread notifications, try fetch notifications since
// the newest read notification to check if any of the unread notifs
// have changed their 'seen' state (marked as read in another session), so
// we can update the state in this session to mark them as read as well.
// The normal maxId-check does not tell if older notifications have changed
const
notifications
=
timelineData
.
data
const
readNotifsIds
=
notifications
.
filter
(
n
=>
n
.
seen
).
map
(
n
=>
n
.
id
)
if
(
readNotifsIds
.
length
)
{
const
possibleMax
=
Math
.
max
(...
readNotifsIds
)
if
(
possibleMax
!==
timelineData
.
maxId
)
{
args
[
'
since
'
]
=
possibleMax
fetchNotifications
({
store
,
args
,
older
})
}
const
numUnseenNotifs
=
notifications
.
length
-
readNotifsIds
.
length
if
(
numUnseenNotifs
>
0
)
{
args
[
'
since
'
]
=
Math
.
max
(...
readNotifsIds
)
fetchNotifications
({
store
,
args
,
older
})
}
return
result
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment