Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
matrix-react-sdk
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Matrix.org
matrix-react-sdk
Commits
876646ac
Commit
876646ac
authored
Jan 21, 2016
by
David Baker
Browse files
Options
Downloads
Patches
Plain Diff
Hopefully make unread loop a bit more digrestable.
parent
13e70e69
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Unread.js
+16
-10
16 additions, 10 deletions
src/Unread.js
with
16 additions
and
10 deletions
src/Unread.js
+
16
−
10
View file @
876646ac
...
...
@@ -36,21 +36,27 @@ module.exports = {
// up probably won't be very much, so if the last couple of events are ones that
// don't count, we don't know if there are any events that do count between where
// we have and the read receipt. We could fetch more history to try & find out,
// but currently we just guess.
This impl assumes there are unread messages
// on the theory that false positives are better than false negatives here.
var
unread
=
true
;
// but currently we just guess.
// Loop through messages, starting with the most recent...
for
(
var
i
=
room
.
timeline
.
length
-
1
;
i
>=
0
;
--
i
)
{
var
ev
=
room
.
timeline
[
i
];
if
(
ev
.
getId
()
==
readUpToId
)
{
unread
=
false
;
break
;
}
if
(
this
.
eventTriggersUnreadCount
(
ev
))
{
break
;
// If we've read up to this event, there's nothing more recents
// that counts and we can stop looking because the user's read
// this and everything before.
return
false
;
}
else
if
(
this
.
eventTriggersUnreadCount
(
ev
))
{
// We've found a message that counts before we hit
// the read marker, so this room is definitely unread.
return
true
;
}
}
return
unread
;
// If we got here, we didn't find a message that counted but didn't
// find the read marker either, so we guess and say that the room
// is unread on the theory that false positives are better than
// false negatives here.
return
true
;
}
};
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