Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
インターネット蟹工船
mastodon
Commits
aaa4d1b0
Commit
aaa4d1b0
authored
Apr 02, 2017
by
Eugen Rochko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep track of which timelines are connected live to avoid redundant
refreshes on navigation
parent
3618cc04
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
4 deletions
+74
-4
app/assets/javascripts/components/actions/timelines.jsx
app/assets/javascripts/components/actions/timelines.jsx
+22
-0
app/assets/javascripts/components/containers/mastodon.jsx
app/assets/javascripts/components/containers/mastodon.jsx
+12
-1
app/assets/javascripts/components/features/community_timeline/index.jsx
...ascripts/components/features/community_timeline/index.jsx
+15
-1
app/assets/javascripts/components/features/public_timeline/index.jsx
...javascripts/components/features/public_timeline/index.jsx
+15
-1
app/assets/javascripts/components/reducers/timelines.jsx
app/assets/javascripts/components/reducers/timelines.jsx
+10
-1
No files found.
app/assets/javascripts/components/actions/timelines.jsx
View file @
aaa4d1b0
...
...
@@ -14,6 +14,9 @@ export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';
export
const
TIMELINE_SCROLL_TOP
=
'
TIMELINE_SCROLL_TOP
'
;
export
const
TIMELINE_CONNECT
=
'
TIMELINE_CONNECT
'
;
export
const
TIMELINE_DISCONNECT
=
'
TIMELINE_DISCONNECT
'
;
export
function
refreshTimelineSuccess
(
timeline
,
statuses
,
skipLoading
,
next
)
{
return
{
type
:
TIMELINE_REFRESH_SUCCESS
,
...
...
@@ -76,6 +79,11 @@ export function refreshTimeline(timeline, id = null) {
let
skipLoading
=
false
;
if
(
newestId
!==
null
&&
getState
().
getIn
([
'
timelines
'
,
timeline
,
'
loaded
'
])
&&
(
id
===
null
||
getState
().
getIn
([
'
timelines
'
,
timeline
,
'
id
'
])
===
id
))
{
if
(
id
===
null
&&
getState
().
getIn
([
'
timelines
'
,
timeline
,
'
online
'
]))
{
// Skip refreshing when timeline is live anyway
return
;
}
params
=
{
...
params
,
since_id
:
newestId
};
skipLoading
=
true
;
}
...
...
@@ -162,3 +170,17 @@ export function scrollTopTimeline(timeline, top) {
top
};
};
export
function
connectTimeline
(
timeline
)
{
return
{
type
:
TIMELINE_CONNECT
,
timeline
};
};
export
function
disconnectTimeline
(
timeline
)
{
return
{
type
:
TIMELINE_DISCONNECT
,
timeline
};
};
app/assets/javascripts/components/containers/mastodon.jsx
View file @
aaa4d1b0
...
...
@@ -4,7 +4,9 @@ import {
refreshTimelineSuccess
,
updateTimeline
,
deleteFromTimelines
,
refreshTimeline
refreshTimeline
,
connectTimeline
,
disconnectTimeline
}
from
'
../actions/timelines
'
;
import
{
updateNotifications
,
refreshNotifications
}
from
'
../actions/notifications
'
;
import
createBrowserHistory
from
'
history/lib/createBrowserHistory
'
;
...
...
@@ -70,6 +72,14 @@ const Mastodon = React.createClass({
this
.
subscription
=
createStream
(
accessToken
,
'
user
'
,
{
connected
()
{
store
.
dispatch
(
connectTimeline
(
'
home
'
));
},
disconnected
()
{
store
.
dispatch
(
disconnectTimeline
(
'
home
'
));
},
received
(
data
)
{
switch
(
data
.
event
)
{
case
'
update
'
:
...
...
@@ -85,6 +95,7 @@ const Mastodon = React.createClass({
},
reconnected
()
{
store
.
dispatch
(
connectTimeline
(
'
home
'
));
store
.
dispatch
(
refreshTimeline
(
'
home
'
));
store
.
dispatch
(
refreshNotifications
());
}
...
...
app/assets/javascripts/components/features/community_timeline/index.jsx
View file @
aaa4d1b0
...
...
@@ -5,7 +5,9 @@ import Column from '../ui/components/column';
import
{
refreshTimeline
,
updateTimeline
,
deleteFromTimelines
deleteFromTimelines
,
connectTimeline
,
disconnectTimeline
}
from
'
../../actions/timelines
'
;
import
{
defineMessages
,
injectIntl
,
FormattedMessage
}
from
'
react-intl
'
;
import
ColumnBackButtonSlim
from
'
../../components/column_back_button_slim
'
;
...
...
@@ -44,6 +46,18 @@ const CommunityTimeline = React.createClass({
subscription
=
createStream
(
accessToken
,
'
public:local
'
,
{
connected
()
{
dispatch
(
connectTimeline
(
'
community
'
));
},
reconnected
()
{
dispatch
(
connectTimeline
(
'
community
'
));
},
disconnected
()
{
dispatch
(
disconnectTimeline
(
'
community
'
));
},
received
(
data
)
{
switch
(
data
.
event
)
{
case
'
update
'
:
...
...
app/assets/javascripts/components/features/public_timeline/index.jsx
View file @
aaa4d1b0
...
...
@@ -5,7 +5,9 @@ import Column from '../ui/components/column';
import
{
refreshTimeline
,
updateTimeline
,
deleteFromTimelines
deleteFromTimelines
,
connectTimeline
,
disconnectTimeline
}
from
'
../../actions/timelines
'
;
import
{
defineMessages
,
injectIntl
,
FormattedMessage
}
from
'
react-intl
'
;
import
ColumnBackButtonSlim
from
'
../../components/column_back_button_slim
'
;
...
...
@@ -44,6 +46,18 @@ const PublicTimeline = React.createClass({
subscription
=
createStream
(
accessToken
,
'
public
'
,
{
connected
()
{
dispatch
(
connectTimeline
(
'
public
'
));
},
reconnected
()
{
dispatch
(
connectTimeline
(
'
public
'
));
},
disconnected
()
{
dispatch
(
disconnectTimeline
(
'
public
'
));
},
received
(
data
)
{
switch
(
data
.
event
)
{
case
'
update
'
:
...
...
app/assets/javascripts/components/reducers/timelines.jsx
View file @
aaa4d1b0
...
...
@@ -7,7 +7,9 @@ import {
TIMELINE_EXPAND_SUCCESS
,
TIMELINE_EXPAND_REQUEST
,
TIMELINE_EXPAND_FAIL
,
TIMELINE_SCROLL_TOP
TIMELINE_SCROLL_TOP
,
TIMELINE_CONNECT
,
TIMELINE_DISCONNECT
}
from
'
../actions/timelines
'
;
import
{
REBLOG_SUCCESS
,
...
...
@@ -35,6 +37,7 @@ const initialState = Immutable.Map({
path
:
()
=>
'
/api/v1/timelines/home
'
,
next
:
null
,
isLoading
:
false
,
online
:
false
,
loaded
:
false
,
top
:
true
,
unread
:
0
,
...
...
@@ -45,6 +48,7 @@ const initialState = Immutable.Map({
path
:
()
=>
'
/api/v1/timelines/public
'
,
next
:
null
,
isLoading
:
false
,
online
:
false
,
loaded
:
false
,
top
:
true
,
unread
:
0
,
...
...
@@ -56,6 +60,7 @@ const initialState = Immutable.Map({
next
:
null
,
params
:
{
local
:
true
},
isLoading
:
false
,
online
:
false
,
loaded
:
false
,
top
:
true
,
unread
:
0
,
...
...
@@ -300,6 +305,10 @@ export default function timelines(state = initialState, action) {
return
filterTimelines
(
state
,
action
.
relationship
,
action
.
statuses
);
case
TIMELINE_SCROLL_TOP
:
return
updateTop
(
state
,
action
.
timeline
,
action
.
top
);
case
TIMELINE_CONNECT
:
return
state
.
setIn
([
action
.
timeline
,
'
online
'
],
true
);
case
TIMELINE_DISCONNECT
:
return
state
.
setIn
([
action
.
timeline
,
'
online
'
],
false
);
default
:
return
state
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment