From: Dessalines Date: Sat, 23 Nov 2019 00:18:10 +0000 (-0800) Subject: Fixing issue with missing community. X-Git-Url: http://these/git/%22%7Burl%7D/%22https:/image.com/%7B%60%24%7BghostArchiveUrl%7D/%7BallRss%7D?a=commitdiff_plain;h=bf601b045863a3ac10f3129c5411a44786b54d95;p=lemmy.git Fixing issue with missing community. - Fixes #339 --- diff --git a/server/src/api/community.rs b/server/src/api/community.rs index 87654e64..69113d52 100644 --- a/server/src/api/community.rs +++ b/server/src/api/community.rs @@ -136,7 +136,10 @@ impl Perform for Oper { let community_id = match data.id { Some(id) => id, None => { - Community::read_from_name(&conn, data.name.to_owned().unwrap_or("main".to_string()))?.id + match Community::read_from_name(&conn, data.name.to_owned().unwrap_or("main".to_string())) { + Ok(community) => community.id, + Err(_e) => return Err(APIError::err(&self.op, "couldnt_find_community"))?, + } } }; diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 8f36178c..cfeff085 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -25,7 +25,8 @@ import { fetchLimit, postRefetchSeconds, } from '../utils'; -import { T, i18n } from 'inferno-i18next'; +import { T } from 'inferno-i18next'; +import { i18n } from '../i18next'; interface State { community: CommunityI; @@ -252,6 +253,7 @@ export class Community extends Component { let op: UserOperation = msgOp(msg); if (msg.error) { alert(i18n.t(msg.error)); + this.context.router.history.push('/'); return; } else if (op == UserOperation.GetCommunity) { let res: GetCommunityResponse = msg;