mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-23 04:41:19 +00:00
Fix new post fetching. Fixes #422
This commit is contained in:
parent
04c7f99f67
commit
1e884c6969
2 changed files with 16 additions and 18 deletions
16
ui/src/components/community.tsx
vendored
16
ui/src/components/community.tsx
vendored
|
@ -89,14 +89,7 @@ export class Community extends Component<any, State> {
|
||||||
this.handleSortChange = this.handleSortChange.bind(this);
|
this.handleSortChange = this.handleSortChange.bind(this);
|
||||||
|
|
||||||
this.subscription = WebSocketService.Instance.subject
|
this.subscription = WebSocketService.Instance.subject
|
||||||
.pipe(
|
.pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
|
||||||
retryWhen(errors =>
|
|
||||||
errors.pipe(
|
|
||||||
delay(3000),
|
|
||||||
take(10)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.subscribe(
|
.subscribe(
|
||||||
msg => this.parseMessage(msg),
|
msg => this.parseMessage(msg),
|
||||||
err => console.error(err),
|
err => console.error(err),
|
||||||
|
@ -154,7 +147,7 @@ export class Community extends Component<any, State> {
|
||||||
)}
|
)}
|
||||||
</h5>
|
</h5>
|
||||||
{this.selects()}
|
{this.selects()}
|
||||||
<PostListings posts={this.state.posts} />
|
{this.state.posts && <PostListings posts={this.state.posts} />}
|
||||||
{this.paginator()}
|
{this.paginator()}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-md-4">
|
<div class="col-12 col-md-4">
|
||||||
|
@ -285,6 +278,11 @@ export class Community extends Component<any, State> {
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (op == UserOperation.GetPosts) {
|
} else if (op == UserOperation.GetPosts) {
|
||||||
let res: GetPostsResponse = msg;
|
let res: GetPostsResponse = msg;
|
||||||
|
|
||||||
|
// This is needed to refresh the view
|
||||||
|
this.state.posts = undefined;
|
||||||
|
this.setState(this.state);
|
||||||
|
|
||||||
this.state.posts = res.posts;
|
this.state.posts = res.posts;
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
|
18
ui/src/components/main.tsx
vendored
18
ui/src/components/main.tsx
vendored
|
@ -112,14 +112,7 @@ export class Main extends Component<any, MainState> {
|
||||||
this.handleTypeChange = this.handleTypeChange.bind(this);
|
this.handleTypeChange = this.handleTypeChange.bind(this);
|
||||||
|
|
||||||
this.subscription = WebSocketService.Instance.subject
|
this.subscription = WebSocketService.Instance.subject
|
||||||
.pipe(
|
.pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
|
||||||
retryWhen(errors =>
|
|
||||||
errors.pipe(
|
|
||||||
delay(3000),
|
|
||||||
take(10)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.subscribe(
|
.subscribe(
|
||||||
msg => this.parseMessage(msg),
|
msg => this.parseMessage(msg),
|
||||||
err => console.error(err),
|
err => console.error(err),
|
||||||
|
@ -429,7 +422,9 @@ export class Main extends Component<any, MainState> {
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
{this.selects()}
|
{this.selects()}
|
||||||
<PostListings posts={this.state.posts} showCommunity />
|
{this.state.posts && (
|
||||||
|
<PostListings posts={this.state.posts} showCommunity />
|
||||||
|
)}
|
||||||
{this.paginator()}
|
{this.paginator()}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -601,6 +596,11 @@ export class Main extends Component<any, MainState> {
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (op == UserOperation.GetPosts) {
|
} else if (op == UserOperation.GetPosts) {
|
||||||
let res: GetPostsResponse = msg;
|
let res: GetPostsResponse = msg;
|
||||||
|
|
||||||
|
// This is needed to refresh the view
|
||||||
|
this.state.posts = undefined;
|
||||||
|
this.setState(this.state);
|
||||||
|
|
||||||
this.state.posts = res.posts;
|
this.state.posts = res.posts;
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
|
Loading…
Reference in a new issue