From 3bae46738d17c365b1bba0d8138237e6a3263152 Mon Sep 17 00:00:00 2001 From: N Pex Date: Thu, 12 Oct 2023 09:23:47 +0000 Subject: [PATCH] Implement "get different link" functionality --- src/assets/css/getlink.scss | 7 ++++ src/assets/css/main.scss | 2 +- src/assets/translations/en.json | 1 + src/components/GetLink.vue | 66 +++++++++++++++++++-------------- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/src/assets/css/getlink.scss b/src/assets/css/getlink.scss index 37074d3..81394ae 100644 --- a/src/assets/css/getlink.scss +++ b/src/assets/css/getlink.scss @@ -79,4 +79,11 @@ height: 17px; object-fit: contain; } + + .getlink-buttons { + display: flex; + align-items: center; + flex-direction: column; + margin-top: -20px; + } } diff --git a/src/assets/css/main.scss b/src/assets/css/main.scss index 9ac9dd6..dbcde48 100644 --- a/src/assets/css/main.scss +++ b/src/assets/css/main.scss @@ -105,7 +105,7 @@ body { position:absolute; top:0; bottom:0; right:0; left:0; } .v-btn.text-button { font-family: 'Inter', sans-serif; font-weight: 700; - font-size: 11 * $chat-text-size; + font-size: 11 * $chat-text-size !important; border: none; height: $chat-standard-padding; margin-top: $chat-standard-padding-xs; diff --git a/src/assets/translations/en.json b/src/assets/translations/en.json index fcb4d91..927833a 100644 --- a/src/assets/translations/en.json +++ b/src/assets/translations/en.json @@ -196,6 +196,7 @@ "ready_to_share": "It’s ready to share! A new direct room will open each time someone opens the link.", "scan_title": "Scan this code to start a direct chat", "continue": "Continue", + "different_link": "Get a different link", "qr_image_copied": "Image copied to clipboard" }, "profile": { diff --git a/src/components/GetLink.vue b/src/components/GetLink.vue index 2c68cf8..f19765d 100644 --- a/src/components/GetLink.vue +++ b/src/components/GetLink.vue @@ -11,14 +11,14 @@
Loading login flows...
- - - {{ $t("getlink.continue") }} - +
{{ $t("getlink.qr_image_copied") }}
@@ -78,25 +80,7 @@ export default { mixins: [rememberMeMixin, logoMixin], components: { InteractiveAuth, CopyLink }, data() { - return { - user: new User(this.$config.defaultServer, "", ""), - isValid: false, - loading: false, - message: "", - userErrorMessage: null, - passErrorMessage: null, - hasError: false, - currentLoginServer: "", - loadingLoginFlows: false, - loginFlows: null, - showPasswordField: false, - showPasswordConfirmField: false, - passwordConfirm: "", - showPassword1: false, - showPassword2: false, - passwordValidation: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{12,20}$/, - showQRCopiedToast: false - }; + return this.defaultData(); }, computed: { loggedIn() { @@ -129,9 +113,37 @@ export default { } }, methods: { + defaultData() { +return { + user: new User(this.$config.defaultServer, "", ""), + isValid: false, + loading: false, + message: "", + userErrorMessage: null, + passErrorMessage: null, + hasError: false, + currentLoginServer: "", + loadingLoginFlows: false, + loginFlows: null, + showPasswordFields: true, + passwordConfirm: "", + showPassword1: false, + showPassword2: false, + passwordValidation: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{12,20}$/, + showQRCopiedToast: false + }; + }, goHome() { this.$navigation.push({ name: "Home" }, -1); }, + getDifferentLink() { + this.$store.dispatch("logout"); + this.$nextTick(() => { + // Reset + const obj = this.defaultData(); + Object.keys(obj).forEach(k => this[k] = obj[k]); + }) + }, handleLogin() { if (this.user.user_id && this.user.password) { // Reset errors @@ -178,7 +190,6 @@ export default { }, onPasswordEntered() { if (this.validPassword(this.user.password)) { - this.showPasswordConfirmField = true; this.$nextTick(() => { this.$refs.passwordConfirm.focus(); }); @@ -190,8 +201,7 @@ export default { const server = user.home_server || this.$config.defaultServer; if (server !== this.currentLoginServer) { - this.showPasswordField = false; - this.showPasswordConfirmField = false; + this.showPasswordFields = false; this.currentLoginServer = server; this.loadingLoginFlows = true; @@ -207,8 +217,8 @@ export default { } else { this.message = ""; this.hasError = false; - this.showPasswordField = this.loginFlows.some(f => f.type == "m.login.password"); - if (this.showPasswordField) { + this.showPasswordFields = this.loginFlows.some(f => f.type == "m.login.password"); + if (this.showPasswordFields) { this.$nextTick(() => { this.$refs.password.focus(); });