diff options
author | Dessalines <tyhou13@gmx.com> | 2019-04-25 22:50:42 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-04-25 22:50:42 -0700 |
commit | fba4d372fcc175f1da53b72980c97e09fdb77d9c (patch) | |
tree | 00677a68fec9eb8e2488d6653706fa9ef53c5a1e | |
parent | 9374aefa56a707cafce8740cd45a0d254ea2184f (diff) |
Spamtimer
-rw-r--r-- | server/src/websocket_server/server.rs | 2 | ||||
-rw-r--r-- | ui/src/components/communities.tsx | 2 | ||||
-rw-r--r-- | ui/src/components/login.tsx | 14 |
3 files changed, 13 insertions, 5 deletions
diff --git a/server/src/websocket_server/server.rs b/server/src/websocket_server/server.rs index c99b32a6..dbd1be8d 100644 --- a/server/src/websocket_server/server.rs +++ b/server/src/websocket_server/server.rs @@ -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( diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index 38344007..b5233c22 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -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); diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx index 2a9f8d7d..e6dec2d2 100644 --- a/ui/src/components/login.tsx +++ b/ui/src/components/login.tsx @@ -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) { |