Skip to content

Commit 12c7164

Browse files
authored
Loading animations instead of "no messages" (#660)
1 parent a4c19c3 commit 12c7164

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

Diff for: ui/src/common/LoadingSpinner.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function LoadingSpinner() {
77
return (
88
<DefaultPage title="" maxWidth={250}>
99
<Grid item xs={12} style={{textAlign: 'center'}}>
10-
<CircularProgress size={150} />
10+
<CircularProgress size={40} />
1111
</Grid>
1212
</DefaultPage>
1313
);

Diff for: ui/src/message/Messages.tsx

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import CircularProgress from '@material-ui/core/CircularProgress';
21
import Grid from '@material-ui/core/Grid';
32
import Typography from '@material-ui/core/Typography';
43
import React, {Component} from 'react';
@@ -12,6 +11,7 @@ import {observable} from 'mobx';
1211
import ReactInfinite from 'react-infinite';
1312
import {IMessage} from '../types';
1413
import ConfirmDialog from '../common/ConfirmDialog';
14+
import LoadingSpinner from '../common/LoadingSpinner';
1515

1616
type IProps = RouteComponentProps<{id: string}>;
1717

@@ -87,7 +87,9 @@ class Messages extends Component<IProps & Stores<'messagesStore' | 'appStore'>,
8787
</Button>
8888
</div>
8989
}>
90-
{hasMessages ? (
90+
{!messagesStore.loaded(appId) ? (
91+
<LoadingSpinner />
92+
) : hasMessages ? (
9193
<div style={{width: '100%'}} id="messages">
9294
<ReactInfinite
9395
key={appId}
@@ -97,13 +99,7 @@ class Messages extends Component<IProps & Stores<'messagesStore' | 'appStore'>,
9799
{messages.map(this.renderMessage)}
98100
</ReactInfinite>
99101

100-
{hasMore ? (
101-
<Grid item xs={12} style={{textAlign: 'center'}}>
102-
<CircularProgress size={100} />
103-
</Grid>
104-
) : (
105-
this.label("You've reached the end")
106-
)}
102+
{hasMore ? <LoadingSpinner /> : this.label("You've reached the end")}
107103
</div>
108104
) : (
109105
this.label('No messages')

Diff for: ui/src/message/MessagesStore.ts

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export class MessagesStore {
3535
return this.state[appId] || this.emptyState();
3636
};
3737

38+
public loaded = (appId: number) => this.stateOf(appId, /*create*/ false).loaded;
39+
3840
public canLoadMore = (appId: number) => this.stateOf(appId, /*create*/ false).hasMore;
3941

4042
@action

0 commit comments

Comments
 (0)