]> Untitled Git - lemmy.git/commitdiff
Spamtimer
authorDessalines <tyhou13@gmx.com>
Fri, 26 Apr 2019 05:50:42 +0000 (22:50 -0700)
committerDessalines <tyhou13@gmx.com>
Fri, 26 Apr 2019 05:50:42 +0000 (22:50 -0700)
server/src/websocket_server/server.rs
ui/src/components/communities.tsx
ui/src/components/login.tsx

index c99b32a633eb3aa9109ecbd26f13ea6bb742af99..dbd1be8d58eaebcfba8b8d451904e54e728c9552 100644 (file)
@@ -969,7 +969,7 @@ impl Perform for ListCommunities {
 
     let sort = SortType::from_str(&self.sort)?;
 
-    let communities: Vec<CommunityView> = CommunityView::list(&conn, user_id, sort, self.page, Some(50))?;
+    let communities: Vec<CommunityView> = CommunityView::list(&conn, user_id, sort, self.page, self.limit)?;
 
     // Return the jwt
     Ok(
index 38344007947d0276489e985f4c5987d90d779970..b5233c22264a7ea58a0a03868171372869370a0f 100644 (file)
@@ -33,7 +33,7 @@ export class Communities extends Component<any, CommunitiesState> {
 
     let listCommunitiesForm: ListCommunitiesForm = {
       sort: SortType[SortType.TopAll],
-      limit: 9999,
+      limit: 100,
     }
 
     WebSocketService.Instance.listCommunities(listCommunitiesForm);
index 2a9f8d7d9d45d08ef3c3ffd609293f8c4c0a4d8e..e6dec2d2e086985692b7787f9c93dfd8aa343a90 100644 (file)
@@ -10,6 +10,7 @@ interface State {
   registerForm: RegisterForm;
   loginLoading: boolean;
   registerLoading: boolean;
+  spamTimer: number;
 }
 
 
@@ -28,7 +29,8 @@ export class Login extends Component<any, State> {
       admin: false,
     },
     loginLoading: false,
-    registerLoading: false
+    registerLoading: false,
+    spamTimer: new Date().getTime()
   }
 
   constructor(props: any, context: any) {
@@ -124,6 +126,7 @@ export class Login extends Component<any, State> {
             <input type="password" value={this.state.registerForm.password_verify} onInput={linkEvent(this, this.handleRegisterPasswordVerifyChange)} class="form-control" required />
           </div>
         </div>
+        <input type="hidden" value={this.state.spamTimer} />
         <div class="form-group row">
           <div class="col-sm-10">
             <button type="submit" class="btn btn-secondary">{this.state.registerLoading ? 
@@ -157,9 +160,14 @@ export class Login extends Component<any, State> {
     i.state.registerLoading = true;
     i.setState(i.state);
     event.preventDefault();
-    setTimeout(function(){
+
+    let endTimer = new Date().getTime();
+    let elapsed = endTimer - i.state.spamTimer;
+    if (elapsed > 4500) {
       WebSocketService.Instance.register(i.state.registerForm);
-    }, 10000);
+    } else {
+      location.reload(true);
+    }
   }
 
   handleRegisterUsernameChange(i: Login, event: any) {