Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
matrix-js-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-js-sdk
Commits
f8d233df
Commit
f8d233df
authored
Jun 12, 2017
by
Luke Barnard
Committed by
GitHub
Jun 12, 2017
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' into luke/fix-timeline-window-load-syncish
parents
e6e2f0b3
17cc1284
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/timeline-window.js
+24
-5
24 additions, 5 deletions
src/timeline-window.js
with
24 additions
and
5 deletions
src/timeline-window.js
+
24
−
5
View file @
f8d233df
...
@@ -95,10 +95,30 @@ TimelineWindow.prototype.load = function(initialEventId, initialWindowSize) {
...
@@ -95,10 +95,30 @@ TimelineWindow.prototype.load = function(initialEventId, initialWindowSize) {
const
self
=
this
;
const
self
=
this
;
initialWindowSize
=
initialWindowSize
||
20
;
initialWindowSize
=
initialWindowSize
||
20
;
// given an EventTimeline,
a
nd
an
event
index within it,
initialise our
// given an EventTimeline,
fi
nd
the
event
we were looking for, and
initialise our
// fields so that the event in question is in the middle of the window.
// fields so that the event in question is in the middle of the window.
const
initFields
=
function
(
timeline
,
eventIndex
)
{
const
initFields
=
function
(
timeline
)
{
const
endIndex
=
Math
.
min
(
timeline
.
getEvents
().
length
,
let
eventIndex
;
const
events
=
timeline
.
getEvents
();
if
(
!
initialEventId
)
{
// we were looking for the live timeline: initialise to the end
eventIndex
=
events
.
length
;
}
else
{
for
(
let
i
=
0
;
i
<
events
.
length
;
i
++
)
{
if
(
events
[
i
].
getId
()
==
initialEventId
)
{
eventIndex
=
i
;
break
;
}
}
if
(
eventIndex
===
undefined
)
{
throw
new
Error
(
"
getEventTimeline result didn't include requested event
"
);
}
}
const
endIndex
=
Math
.
min
(
events
.
length
,
eventIndex
+
Math
.
ceil
(
initialWindowSize
/
2
));
eventIndex
+
Math
.
ceil
(
initialWindowSize
/
2
));
const
startIndex
=
Math
.
max
(
0
,
endIndex
-
initialWindowSize
);
const
startIndex
=
Math
.
max
(
0
,
endIndex
-
initialWindowSize
);
self
.
_start
=
new
TimelineIndex
(
timeline
,
startIndex
-
timeline
.
getBaseIndex
());
self
.
_start
=
new
TimelineIndex
(
timeline
,
startIndex
-
timeline
.
getBaseIndex
());
...
@@ -133,9 +153,8 @@ TimelineWindow.prototype.load = function(initialEventId, initialWindowSize) {
...
@@ -133,9 +153,8 @@ TimelineWindow.prototype.load = function(initialEventId, initialWindowSize) {
throw
new
Error
(
"
getEventTimeline result didn't include requested event
"
);
throw
new
Error
(
"
getEventTimeline result didn't include requested event
"
);
});
});
}
else
{
}
else
{
// start with the most recent events
const
tl
=
this
.
_timelineSet
.
getLiveTimeline
();
const
tl
=
this
.
_timelineSet
.
getLiveTimeline
();
initFields
(
tl
,
tl
.
getEvents
().
length
);
initFields
(
tl
);
return
q
();
return
q
();
}
}
};
};
...
...
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