]> Untitled Git - lemmy.git/commitdiff
Fixing issue with missing community.
authorDessalines <tyhou13@gmx.com>
Sat, 23 Nov 2019 00:18:10 +0000 (16:18 -0800)
committerDessalines <tyhou13@gmx.com>
Sat, 23 Nov 2019 00:18:10 +0000 (16:18 -0800)
- Fixes #339

server/src/api/community.rs
ui/src/components/community.tsx

index 87654e6492db89e3cb2126d59db0501be6c4e775..69113d52282db2d0805acfd0739d0a553c705485 100644 (file)
@@ -136,7 +136,10 @@ impl Perform<GetCommunityResponse> for Oper<GetCommunity> {
     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"))?,
+        }
       }
     };
 
index 8f36178c86b9e0678383d2c3700f73784872d118..cfeff085204bf4a24a775832e730f51bf084d4c6 100644 (file)
@@ -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<any, State> {
     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;