Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Pierre Boudes
mastodon
Commits
ec13cfa4
Commit
ec13cfa4
authored
7 years ago
by
Eugen Rochko
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
When a streaming API status arrives, sort it into conversations (#5206)
parent
cdd5ef69
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/javascript/mastodon/actions/timelines.js
+20
-0
20 additions, 0 deletions
app/javascript/mastodon/actions/timelines.js
app/javascript/mastodon/reducers/contexts.js
+17
-5
17 additions, 5 deletions
app/javascript/mastodon/reducers/contexts.js
with
37 additions
and
5 deletions
app/javascript/mastodon/actions/timelines.js
+
20
−
0
View file @
ec13cfa4
...
...
@@ -17,6 +17,8 @@ export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
export
const
TIMELINE_CONNECT
=
'
TIMELINE_CONNECT
'
;
export
const
TIMELINE_DISCONNECT
=
'
TIMELINE_DISCONNECT
'
;
export
const
TIMELINE_CONTEXT_UPDATE
=
'
CONTEXT_UPDATE
'
;
export
function
refreshTimelineSuccess
(
timeline
,
statuses
,
skipLoading
,
next
)
{
return
{
type
:
TIMELINE_REFRESH_SUCCESS
,
...
...
@@ -30,6 +32,16 @@ export function refreshTimelineSuccess(timeline, statuses, skipLoading, next) {
export
function
updateTimeline
(
timeline
,
status
)
{
return
(
dispatch
,
getState
)
=>
{
const
references
=
status
.
reblog
?
getState
().
get
(
'
statuses
'
).
filter
((
item
,
itemId
)
=>
(
itemId
===
status
.
reblog
.
id
||
item
.
get
(
'
reblog
'
)
===
status
.
reblog
.
id
)).
map
((
_
,
itemId
)
=>
itemId
)
:
[];
const
parents
=
[];
if
(
status
.
in_reply_to_id
)
{
let
parent
=
getState
().
getIn
([
'
statuses
'
,
status
.
in_reply_to_id
]);
while
(
parent
.
get
(
'
in_reply_to_id
'
))
{
parents
.
push
(
parent
.
get
(
'
id
'
));
parent
=
getState
().
getIn
([
'
statuses
'
,
parent
.
get
(
'
in_reply_to_id
'
)]);
}
}
dispatch
({
type
:
TIMELINE_UPDATE
,
...
...
@@ -37,6 +49,14 @@ export function updateTimeline(timeline, status) {
status
,
references
,
});
if
(
parents
.
length
>
0
)
{
dispatch
({
type
:
TIMELINE_CONTEXT_UPDATE
,
status
,
references
:
parents
,
});
}
};
};
...
...
This diff is collapsed.
Click to expand it.
app/javascript/mastodon/reducers/contexts.js
+
17
−
5
View file @
ec13cfa4
import
{
CONTEXT_FETCH_SUCCESS
}
from
'
../actions/statuses
'
;
import
{
TIMELINE_DELETE
}
from
'
../actions/timelines
'
;
import
{
Map
as
ImmutableMap
,
List
as
ImmutableList
,
fromJS
}
from
'
immutable
'
;
import
{
TIMELINE_DELETE
,
TIMELINE_CONTEXT_UPDATE
}
from
'
../actions/timelines
'
;
import
{
Map
as
ImmutableMap
,
List
as
ImmutableList
}
from
'
immutable
'
;
const
initialState
=
ImmutableMap
({
ancestors
:
ImmutableMap
(),
...
...
@@ -8,8 +8,8 @@ const initialState = ImmutableMap({
});
const
normalizeContext
=
(
state
,
id
,
ancestors
,
descendants
)
=>
{
const
ancestorsIds
=
ancestors
.
map
(
ancestor
=>
ancestor
.
get
(
'
id
'
));
const
descendantsIds
=
descendants
.
map
(
descendant
=>
descendant
.
get
(
'
id
'
));
const
ancestorsIds
=
ImmutableList
(
ancestors
.
map
(
ancestor
=>
ancestor
.
id
));
const
descendantsIds
=
ImmutableList
(
descendants
.
map
(
descendant
=>
descendant
.
id
));
return
state
.
withMutations
(
map
=>
{
map
.
setIn
([
'
ancestors
'
,
id
],
ancestorsIds
);
...
...
@@ -31,12 +31,24 @@ const deleteFromContexts = (state, id) => {
return
state
;
};
const
updateContext
=
(
state
,
status
,
references
)
=>
{
return
state
.
update
(
'
descendants
'
,
map
=>
{
references
.
forEach
(
parentId
=>
{
map
=
map
.
update
(
parentId
,
ImmutableList
(),
list
=>
list
.
push
(
status
.
id
));
});
return
map
;
});
};
export
default
function
contexts
(
state
=
initialState
,
action
)
{
switch
(
action
.
type
)
{
case
CONTEXT_FETCH_SUCCESS
:
return
normalizeContext
(
state
,
action
.
id
,
fromJS
(
action
.
ancestors
)
,
fromJS
(
action
.
descendants
)
)
;
return
normalizeContext
(
state
,
action
.
id
,
action
.
ancestors
,
action
.
descendants
);
case
TIMELINE_DELETE
:
return
deleteFromContexts
(
state
,
action
.
id
);
case
TIMELINE_CONTEXT_UPDATE
:
return
updateContext
(
state
,
action
.
status
,
action
.
references
);
default
:
return
state
;
}
...
...
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