diff options
Diffstat (limited to 'ui/src/components/community.tsx')
-rw-r--r-- | ui/src/components/community.tsx | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 357fe260..9d02dd86 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -25,6 +25,7 @@ import { routeSortTypeToEnum, fetchLimit, postRefetchSeconds, + toast, } from '../utils'; import { T } from 'inferno-i18next'; import { i18n } from '../i18next'; @@ -148,7 +149,7 @@ export class Community extends Component<any, State> { )} </h5> {this.selects()} - {this.state.posts && <PostListings posts={this.state.posts} />} + <PostListings posts={this.state.posts} /> {this.paginator()} </div> <div class="col-12 col-md-4"> @@ -193,12 +194,14 @@ export class Community extends Component<any, State> { <T i18nKey="prev">#</T> </button> )} - <button - class="btn btn-sm btn-secondary" - onClick={linkEvent(this, this.nextPage)} - > - <T i18nKey="next">#</T> - </button> + {this.state.posts.length == fetchLimit && ( + <button + class="btn btn-sm btn-secondary" + onClick={linkEvent(this, this.nextPage)} + > + <T i18nKey="next">#</T> + </button> + )} </div> ); } @@ -256,7 +259,7 @@ export class Community extends Component<any, State> { console.log(msg); let res = wsJsonToRes(msg); if (res.error) { - alert(i18n.t(res.error)); + toast(i18n.t(msg.error), 'danger'); this.context.router.history.push('/'); return; } else if (res.op == UserOperation.GetCommunity) { @@ -279,12 +282,6 @@ export class Community extends Component<any, State> { this.setState(this.state); } else if (res.op == UserOperation.GetPosts) { let data = res.data as GetPostsResponse; - - // TODO rework this - // This is needed to refresh the view - this.state.posts = undefined; - this.setState(this.state); - this.state.posts = data.posts; this.state.loading = false; this.setState(this.state); |