Skip to content

Commit 11404b8

Browse files
committed
clean up how Streams knows about loading state
1 parent bb8583b commit 11404b8

File tree

1 file changed

+7
-9
lines changed
  • source/views/streaming/streams

1 file changed

+7
-9
lines changed

source/views/streaming/streams/list.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,20 @@ export class StreamListView extends React.PureComponent {
3838

3939
state: {
4040
error: ?Error,
41-
loaded: boolean,
41+
loading: boolean,
4242
refreshing: boolean,
4343
streams: Array<{title: string, data: Array<StreamType>}>,
4444
} = {
4545
error: null,
46-
loaded: false,
46+
loading: true,
4747
refreshing: false,
4848
streams: [],
4949
}
5050

5151
componentWillMount() {
52-
this.getStreams()
52+
this.getStreams().then(() => {
53+
this.setState(() => ({loading: false}))
54+
})
5355
}
5456

5557
refresh = async () => {
@@ -101,11 +103,7 @@ export class StreamListView extends React.PureComponent {
101103
const grouped = groupBy(processed, j => j.$groupBy)
102104
const mapped = toPairs(grouped).map(([title, data]) => ({title, data}))
103105

104-
this.setState(() => ({
105-
error: null,
106-
loaded: true,
107-
streams: mapped,
108-
}))
106+
this.setState(() => ({error: null, streams: mapped}))
109107
} catch (error) {
110108
this.setState(() => ({error: error.message}))
111109
console.warn(error)
@@ -121,7 +119,7 @@ export class StreamListView extends React.PureComponent {
121119
renderItem = ({item}: {item: StreamType}) => <StreamRow stream={item} />
122120

123121
render() {
124-
if (!this.state.loaded) {
122+
if (this.state.loading) {
125123
return <LoadingView />
126124
}
127125

0 commit comments

Comments
 (0)