mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-22 14:45:20 +00:00
Show cross-posts for isomorphic loading. Fixes #113
This commit is contained in:
parent
9dcc998878
commit
baee514303
|
@ -101,9 +101,12 @@ export class Post extends Component<any, PostState> {
|
||||||
this.state.categories = this.isoData.routeData[1].categories;
|
this.state.categories = this.isoData.routeData[1].categories;
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
|
|
||||||
if (isBrowser() && this.state.commentId) {
|
if (isBrowser()) {
|
||||||
|
this.fetchCrossPosts();
|
||||||
|
if (this.state.commentId) {
|
||||||
this.scrollCommentIntoView();
|
this.scrollCommentIntoView();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.fetchPost();
|
this.fetchPost();
|
||||||
WebSocketService.Instance.send(wsClient.listCategories());
|
WebSocketService.Instance.send(wsClient.listCategories());
|
||||||
|
@ -118,6 +121,20 @@ export class Post extends Component<any, PostState> {
|
||||||
WebSocketService.Instance.send(wsClient.getPost(form));
|
WebSocketService.Instance.send(wsClient.getPost(form));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchCrossPosts() {
|
||||||
|
if (this.state.postRes.post_view.post.url) {
|
||||||
|
let form: Search = {
|
||||||
|
q: this.state.postRes.post_view.post.url,
|
||||||
|
type_: SearchType.Url,
|
||||||
|
sort: SortType.TopAll,
|
||||||
|
page: 1,
|
||||||
|
limit: 6,
|
||||||
|
auth: authField(false),
|
||||||
|
};
|
||||||
|
WebSocketService.Instance.send(wsClient.search(form));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
|
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
|
||||||
let pathSplit = req.path.split('/');
|
let pathSplit = req.path.split('/');
|
||||||
let promises: Promise<any>[] = [];
|
let promises: Promise<any>[] = [];
|
||||||
|
@ -463,18 +480,7 @@ export class Post extends Component<any, PostState> {
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
|
|
||||||
// Get cross-posts
|
// Get cross-posts
|
||||||
if (this.state.postRes.post_view.post.url) {
|
this.fetchCrossPosts();
|
||||||
let form: Search = {
|
|
||||||
q: this.state.postRes.post_view.post.url,
|
|
||||||
type_: SearchType.Url,
|
|
||||||
sort: SortType.TopAll,
|
|
||||||
page: 1,
|
|
||||||
limit: 6,
|
|
||||||
auth: authField(false),
|
|
||||||
};
|
|
||||||
WebSocketService.Instance.send(wsClient.search(form));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
setupTippy();
|
setupTippy();
|
||||||
} else if (op == UserOperation.CreateComment) {
|
} else if (op == UserOperation.CreateComment) {
|
||||||
|
|
Loading…
Reference in a new issue