Skip to content

Commit

Permalink
Loading animations instead of "no messages" (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
MexHigh authored Jun 22, 2024
1 parent a4c19c3 commit 12c7164
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ui/src/common/LoadingSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function LoadingSpinner() {
return (
<DefaultPage title="" maxWidth={250}>
<Grid item xs={12} style={{textAlign: 'center'}}>
<CircularProgress size={150} />
<CircularProgress size={40} />
</Grid>
</DefaultPage>
);
Expand Down
14 changes: 5 additions & 9 deletions ui/src/message/Messages.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import CircularProgress from '@material-ui/core/CircularProgress';
import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography';
import React, {Component} from 'react';
Expand All @@ -12,6 +11,7 @@ import {observable} from 'mobx';
import ReactInfinite from 'react-infinite';
import {IMessage} from '../types';
import ConfirmDialog from '../common/ConfirmDialog';
import LoadingSpinner from '../common/LoadingSpinner';

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

Expand Down Expand Up @@ -87,7 +87,9 @@ class Messages extends Component<IProps & Stores<'messagesStore' | 'appStore'>,
</Button>
</div>
}>
{hasMessages ? (
{!messagesStore.loaded(appId) ? (
<LoadingSpinner />
) : hasMessages ? (
<div style={{width: '100%'}} id="messages">
<ReactInfinite
key={appId}
Expand All @@ -97,13 +99,7 @@ class Messages extends Component<IProps & Stores<'messagesStore' | 'appStore'>,
{messages.map(this.renderMessage)}
</ReactInfinite>

{hasMore ? (
<Grid item xs={12} style={{textAlign: 'center'}}>
<CircularProgress size={100} />
</Grid>
) : (
this.label("You've reached the end")
)}
{hasMore ? <LoadingSpinner /> : this.label("You've reached the end")}
</div>
) : (
this.label('No messages')
Expand Down
2 changes: 2 additions & 0 deletions ui/src/message/MessagesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export class MessagesStore {
return this.state[appId] || this.emptyState();
};

public loaded = (appId: number) => this.stateOf(appId, /*create*/ false).loaded;

public canLoadMore = (appId: number) => this.stateOf(appId, /*create*/ false).hasMore;

@action
Expand Down

0 comments on commit 12c7164

Please sign in to comment.