diff options
Diffstat (limited to 'ui/src/components/main.tsx')
-rw-r--r-- | ui/src/components/main.tsx | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 1ccebc80..9f16edb5 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -34,6 +34,7 @@ import { postRefetchSeconds, pictshareAvatarThumbnail, showAvatars, + toast, } from '../utils'; import { i18n } from '../i18next'; import { T } from 'inferno-i18next'; @@ -422,9 +423,7 @@ export class Main extends Component<any, MainState> { ) : ( <div> {this.selects()} - {this.state.posts && ( - <PostListings posts={this.state.posts} showCommunity /> - )} + <PostListings posts={this.state.posts} showCommunity /> {this.paginator()} </div> )} @@ -480,12 +479,14 @@ export class Main extends Component<any, MainState> { <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> ); } @@ -566,7 +567,7 @@ export class Main extends Component<any, MainState> { console.log(msg); let res = wsJsonToRes(msg); if (res.error) { - alert(i18n.t(res.error)); + toast(i18n.t(msg.error), 'danger'); return; } else if (res.op == UserOperation.GetFollowedCommunities) { let data = res.data as GetFollowedCommunitiesResponse; @@ -596,12 +597,6 @@ export class Main extends Component<any, MainState> { this.setState(this.state); } else if (res.op == UserOperation.GetPosts) { let data = res.data as GetPostsResponse; - - // This is needed to refresh the view - // TODO mess with this - this.state.posts = undefined; - this.setState(this.state); - this.state.posts = data.posts; this.state.loading = false; this.setState(this.state); |