diff options
Diffstat (limited to 'ui/src')
-rw-r--r-- | ui/src/components/comment-form.tsx | 4 | ||||
-rw-r--r-- | ui/src/components/login.tsx | 49 | ||||
-rw-r--r-- | ui/src/components/sponsors.tsx | 15 | ||||
-rw-r--r-- | ui/src/version.ts | 2 |
4 files changed, 61 insertions, 9 deletions
diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 72a604b9..61ee3d77 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -263,7 +263,9 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> { // If its a comment edit, only check that its from your user, and that its a // text edit only - (op == UserOperation.EditComment && data.comment.content) + (data.comment.creator_id == UserService.Instance.user.id && + op == UserOperation.EditComment && + data.comment.content) ) { this.state.previewMode = false; this.state.loading = false; diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx index ce04d0d4..97899345 100644 --- a/ui/src/components/login.tsx +++ b/ui/src/components/login.tsx @@ -20,6 +20,11 @@ interface State { loginLoading: boolean; registerLoading: boolean; enable_nsfw: boolean; + mathQuestion: { + a: number; + b: number; + answer: number; + }; } export class Login extends Component<any, State> { @@ -40,6 +45,11 @@ export class Login extends Component<any, State> { loginLoading: false, registerLoading: false, enable_nsfw: undefined, + mathQuestion: { + a: Math.floor(Math.random() * 10) + 1, + b: Math.floor(Math.random() * 10) + 1, + answer: undefined, + }, }; constructor(props: any, context: any) { @@ -215,6 +225,23 @@ export class Login extends Component<any, State> { /> </div> </div> + <div class="form-group row"> + <label class="col-sm-10 col-form-label" htmlFor="register-math"> + {i18n.t('what_is')}{' '} + {`${this.state.mathQuestion.a} + ${this.state.mathQuestion.b}?`} + </label> + + <div class="col-sm-2"> + <input + type="number" + id="register-math" + class="form-control" + value={this.state.mathQuestion.answer} + onInput={linkEvent(this, this.handleMathAnswerChange)} + required + /> + </div> + </div> {this.state.enable_nsfw && ( <div class="form-group row"> <div class="col-sm-10"> @@ -235,7 +262,11 @@ export class Login extends Component<any, State> { )} <div class="form-group row"> <div class="col-sm-10"> - <button type="submit" class="btn btn-secondary"> + <button + type="submit" + class="btn btn-secondary" + disabled={this.mathCheck} + > {this.state.registerLoading ? ( <svg class="icon icon-spinner spin"> <use xlinkHref="#icon-spinner"></use> @@ -272,7 +303,9 @@ export class Login extends Component<any, State> { i.state.registerLoading = true; i.setState(i.state); - WebSocketService.Instance.register(i.state.registerForm); + if (!i.mathCheck) { + WebSocketService.Instance.register(i.state.registerForm); + } } handleRegisterUsernameChange(i: Login, event: any) { @@ -303,6 +336,11 @@ export class Login extends Component<any, State> { i.setState(i.state); } + handleMathAnswerChange(i: Login, event: any) { + i.state.mathQuestion.answer = event.target.value; + i.setState(i.state); + } + handlePasswordReset(i: Login) { event.preventDefault(); let resetForm: PasswordResetForm = { @@ -311,6 +349,13 @@ export class Login extends Component<any, State> { WebSocketService.Instance.passwordReset(resetForm); } + get mathCheck(): boolean { + return ( + this.state.mathQuestion.answer != + this.state.mathQuestion.a + this.state.mathQuestion.b + ); + } + parseMessage(msg: WebSocketJsonResponse) { let res = wsJsonToRes(msg); if (msg.error) { diff --git a/ui/src/components/sponsors.tsx b/ui/src/components/sponsors.tsx index 06e13524..4561bc30 100644 --- a/ui/src/components/sponsors.tsx +++ b/ui/src/components/sponsors.tsx @@ -6,10 +6,11 @@ import { repoUrl } from '../utils'; interface SilverUser { name: string; - link: string; + link?: string; } let general = [ + 'twilight loki', 'Andrew Plaza', 'Jonathan Cremin', 'Arthur Nieuwland', @@ -19,7 +20,7 @@ let general = [ 'Andre Vallestero', 'NotTooHighToHack', ]; -let highlighted = ['Oskenso Kashi', 'Alex Benishek']; +let highlighted = ['DiscountFuneral', 'Oskenso Kashi', 'Alex Benishek']; let silver: Array<SilverUser> = [ { name: 'Redjoker', @@ -89,9 +90,13 @@ export class Sponsors extends Component<any, any> { {silver.map(s => ( <div class="card col-12 col-md-2"> <div> - <a href={s.link} target="_blank" rel="noopener"> - 💎 {s.name} - </a> + {s.link ? ( + <a href={s.link} target="_blank" rel="noopener"> + 💎 {s.name} + </a> + ) : ( + <div>💎 {s.name}</div> + )} </div> </div> ))} diff --git a/ui/src/version.ts b/ui/src/version.ts index 8ad27e7c..709137ef 100644 --- a/ui/src/version.ts +++ b/ui/src/version.ts @@ -1 +1 @@ -export const version: string = 'v0.7.6'; +export const version: string = 'v0.7.8'; |