Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mastofe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Pleroma
mastofe
Commits
28cbfb9f
Commit
28cbfb9f
authored
7 years ago
by
Nolan Lawson
Committed by
Eugen Rochko
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Simplify isIntersecting in status_list.js (#3371)
parent
189a06d2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/javascript/mastodon/components/status_list.js
+22
-5
22 additions, 5 deletions
app/javascript/mastodon/components/status_list.js
with
22 additions
and
5 deletions
app/javascript/mastodon/components/status_list.js
+
22
−
5
View file @
28cbfb9f
...
...
@@ -27,7 +27,8 @@ class StatusList extends ImmutablePureComponent {
};
state
=
{
isIntersecting
:
[{
}],
isIntersecting
:
{},
intersectionCount
:
0
,
}
statusRefQueue
=
[]
...
...
@@ -65,15 +66,31 @@ class StatusList extends ImmutablePureComponent {
attachIntersectionObserver
()
{
const
onIntersection
=
(
entries
)
=>
{
this
.
setState
(
state
=>
{
const
isIntersecting
=
{
};
entries
.
forEach
(
entry
=>
{
const
statusId
=
entry
.
target
.
getAttribute
(
'
data-id
'
);
state
.
isIntersecting
[
0
][
statusId
]
=
entry
.
isIntersecting
;
state
.
isIntersecting
[
statusId
]
=
entry
.
isIntersecting
;
});
return
{
isIntersecting
:
[
state
.
isIntersecting
[
0
]]
};
// isIntersecting is a map of DOM data-id's to booleans (true for
// intersecting, false for non-intersecting).
//
// We always want to return true in shouldComponentUpdate() if
// this object changes, because onIntersection() is only called if
// something has changed.
//
// Now, we *could* use an immutable map or some other structure to
// diff the full map, but that would be pointless because the browser
// has already informed us that something has changed. So we can just
// use a regular object, which will be diffed by ImmutablePureComponent
// based on reference equality (i.e. it's always "unchanged") and
// then we just increment intersectionCount to force a change.
return
{
isIntersecting
:
state
.
isIntersecting
,
intersectionCount
:
state
.
intersectionCount
+
1
,
};
});
};
...
...
@@ -122,7 +139,7 @@ class StatusList extends ImmutablePureComponent {
render
()
{
const
{
statusIds
,
onScrollToBottom
,
scrollKey
,
shouldUpdateScroll
,
isLoading
,
isUnread
,
hasMore
,
prepend
,
emptyMessage
}
=
this
.
props
;
const
isIntersecting
=
this
.
state
.
isIntersecting
[
0
]
;
const
{
isIntersecting
}
=
this
.
state
;
let
loadMore
=
null
;
let
scrollableArea
=
null
;
...
...
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