);
// This can be single or multiple communities given
- this.state.communities = communitiesRes
- .map(c => c.communities)
- .unwrapOr([communityRes.map(c => c.community_view).unwrap()]);
+ communitiesRes.match({
+ some: res => (this.state.communities = res.communities),
+ none: void 0,
+ });
+
+ communityRes.match({
+ some: res => (this.state.communities = [res.community_view]),
+ none: void 0,
+ });
this.state.creatorDetails = Some(
this.isoData.routeData[2] as GetPersonDetailsResponse
let creator_id: Option<number> =
this.state.creatorId == 0 ? None : Some(this.state.creatorId);
- console.log(community_id.unwrapOr(-22));
-
let form = new SearchForm({
q: this.state.q,
community_id,
}
export async function getSiteMetadata(url: string) {
- let form: GetSiteMetadata = {
+ let form = new GetSiteMetadata({
url,
- };
+ });
let client = new LemmyHttp(httpBase);
return client.getSiteMetadata(form);
}
}
export async function fetchCommunities(q: string) {
- let form: Search = {
+ let form = new Search({
q,
type_: Some(SearchType.Communities),
sort: Some(SortType.TopAll),
community_name: None,
creator_id: None,
auth: auth(false).ok(),
- };
+ });
let client = new LemmyHttp(httpBase);
return client.search(form);
}
export async function fetchUsers(q: string) {
- let form: Search = {
+ let form = new Search({
q,
type_: Some(SearchType.Users),
sort: Some(SortType.TopAll),
community_name: None,
creator_id: None,
auth: auth(false).ok(),
- };
+ });
let client = new LemmyHttp(httpBase);
return client.search(form);
}