]> Untitled Git - lemmy.git/commitdiff
Fixes for login screen, server
authorDessalines <tyhou13@gmx.com>
Thu, 25 Apr 2019 15:51:23 +0000 (08:51 -0700)
committerDessalines <tyhou13@gmx.com>
Thu, 25 Apr 2019 15:51:23 +0000 (08:51 -0700)
server/src/websocket_server/server.rs
ui/src/components/login.tsx

index 79707bf47691ede8f37fba0f0ea00394ddabd160..914bf9f2b258a39b76c46b8f2afd778d3c52d71e 100644 (file)
@@ -1311,12 +1311,12 @@ impl Perform for EditComment {
 
     let user_id = claims.id;
 
+    let orig_comment = CommentView::read(&conn, self.edit_id, None)?;
 
     // You are allowed to mark the comment as read even if you're banned.
     if self.read.is_none() {
 
       // Verify its the creator or a mod, or an admin
-      let orig_comment = CommentView::read(&conn, self.edit_id, None)?;
       let mut editors: Vec<i32> = vec![self.creator_id];
       editors.append(
         &mut CommunityModeratorView::for_community(&conn, orig_comment.community_id)
@@ -1358,7 +1358,7 @@ impl Perform for EditComment {
       creator_id: self.creator_id,
       removed: self.removed.to_owned(),
       read: self.read.to_owned(),
-      updated: if self.read.is_some() { None } else {Some(naive_now())}
+      updated: if self.read.is_some() { orig_comment.updated } else {Some(naive_now())}
       };
 
     let _updated_comment = match Comment::update(&conn, self.edit_id, &comment_form) {
index d66466b15950f655592d4c6ed2f370a00d9ad6c5..bab7b06f498ba789bb0d664b7db46d80f8cb5d43 100644 (file)
@@ -12,28 +12,29 @@ interface State {
   registerLoading: boolean;
 }
 
-let emptyState: State = {
-  loginForm: {
-    username_or_email: undefined,
-    password: undefined
-  },
-  registerForm: {
-    username: undefined,
-    password: undefined,
-    password_verify: undefined,
-    admin: false,
-  },
-  loginLoading: false,
-  registerLoading: false
-}
 
 export class Login extends Component<any, State> {
   private subscription: Subscription;
 
+  emptyState: State = {
+    loginForm: {
+      username_or_email: undefined,
+      password: undefined
+    },
+    registerForm: {
+      username: undefined,
+      password: undefined,
+      password_verify: undefined,
+      admin: false,
+    },
+    loginLoading: false,
+    registerLoading: false
+  }
+
   constructor(props: any, context: any) {
     super(props, context);
 
-    this.state = emptyState;
+    this.state = this.emptyState;
 
     this.subscription = WebSocketService.Instance.subject
     .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
@@ -183,8 +184,7 @@ export class Login extends Component<any, State> {
     let op: UserOperation = msgOp(msg);
     if (msg.error) {
       alert(msg.error);
-      this.state.loginLoading = false;
-      this.state.registerLoading = false;
+      this.state = this.emptyState;
       this.setState(this.state);
       return;
     } else {