From e9a9b7d447241eef977e84646dd25e06d401d798 Mon Sep 17 00:00:00 2001 From: Marco Ambrosini Date: Mon, 23 Mar 2020 14:52:32 +0100 Subject: [PATCH 1/3] Generalise guest rename logic into SetGuestUsername component for reuse Signed-off-by: Marco Ambrosini --- src/components/RightSidebar/RightSidebar.vue | 91 +----------- src/components/SetGuestUsername.vue | 137 +++++++++++++++++++ 2 files changed, 140 insertions(+), 88 deletions(-) create mode 100644 src/components/SetGuestUsername.vue diff --git a/src/components/RightSidebar/RightSidebar.vue b/src/components/RightSidebar/RightSidebar.vue index 5d1b847a1a5..54ed04d15a0 100644 --- a/src/components/RightSidebar/RightSidebar.vue +++ b/src/components/RightSidebar/RightSidebar.vue @@ -129,36 +129,7 @@ :name="conversation.displayName" /> -
-

- {{ t('spreed', 'Display name: ') }} {{ actorDisplayName ? actorDisplayName : t('spreed', 'Guest') }} - -

-
- - -
-
+ @@ -181,8 +152,8 @@ import { setConversationName, } from '../../services/conversationsService' import isInLobby from '../../mixins/isInLobby' -import { setGuestUserName } from '../../services/participantsService' import { generateUrl } from '@nextcloud/router' +import SetGuestUsername from '../SetGuestUsername' export default { name: 'RightSidebar', @@ -197,6 +168,7 @@ export default { ChatView, CollectionList, ParticipantsTab, + SetGuestUsername, }, mixins: [ @@ -218,8 +190,6 @@ export default { password: '', // Switch for the password-editing operation isEditingPassword: false, - guestUserName: '', - isEditingUsername: false, // Changes the conversation title into an input field for renaming isRenamingConversation: false, // The conversation name (while editing) @@ -255,10 +225,6 @@ export default { return this.$store.getters.getUserId() }, - actorDisplayName() { - return this.$store.getters.getDisplayName() - }, - isFavorited() { if (!this.getUserId) { return null @@ -428,35 +394,6 @@ export default { this.password = '' this.isEditingPassword = false }, - async handleChooseUserName() { - const previousName = this.$store.getters.getDisplayName() - try { - this.$store.dispatch('setDisplayName', this.guestUserName) - this.$store.dispatch('forceGuestName', { - token: this.token, - actorId: this.$store.getters.getActorId().substring(6), - actorDisplayName: this.guestUserName, - }) - await setGuestUserName(this.token, this.guestUserName) - this.isEditingUsername = false - } catch (exception) { - this.$store.dispatch('setDisplayName', previousName) - this.$store.dispatch('forceGuestName', { - token: this.token, - actorId: this.$store.getters.getActorId().substring(6), - actorDisplayName: previousName, - }) - console.debug(exception) - } - }, - - /** For when the currentUser is guest */ - handleEditUsername() { - this.isEditingUsername = !this.isEditingUsername - this.$nextTick(() => { - this.$refs.usernameInput.focus() - }) - }, handleRenameConversation() { // Copy the current conversation's title into the renaming title @@ -511,26 +448,4 @@ export default { padding: 0; } -/** Username form for guest users */ -.username-form { - padding: 0 12px; - & .icon-rename { - margin-left: 8px; - padding-left: 36px; - background-position: 12px; - } - &__wrapper { - display: flex; - } - &__input { - padding-right: var(--clickable-area); - width: 300px; - } - &__button { - margin-left: -44px; - background-color: transparent; - border: none; - } -} - diff --git a/src/components/SetGuestUsername.vue b/src/components/SetGuestUsername.vue new file mode 100644 index 00000000000..e4915a9759b --- /dev/null +++ b/src/components/SetGuestUsername.vue @@ -0,0 +1,137 @@ + + + + + + + From f6b2b1b54eef28319cfbab5f4c443aaf1768532c Mon Sep 17 00:00:00 2001 From: Marco Ambrosini Date: Mon, 23 Mar 2020 14:58:03 +0100 Subject: [PATCH 2/3] Add guest username setting to lobby Signed-off-by: Marco Ambrosini --- src/components/LobbyScreen.vue | 25 +++++++++++++++++++++---- src/components/SetGuestUsername.vue | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/LobbyScreen.vue b/src/components/LobbyScreen.vue index b3dd3579123..f0dd96e6359 100644 --- a/src/components/LobbyScreen.vue +++ b/src/components/LobbyScreen.vue @@ -19,20 +19,28 @@ --> + + diff --git a/src/components/SetGuestUsername.vue b/src/components/SetGuestUsername.vue index e4915a9759b..f85e8c4b390 100644 --- a/src/components/SetGuestUsername.vue +++ b/src/components/SetGuestUsername.vue @@ -115,6 +115,7 @@ export default { /** Username form for guest users */ .username-form { padding: 0 12px; + margin:auto; & .icon-rename { margin-left: 8px; padding-left: 36px; @@ -125,7 +126,7 @@ export default { } &__input { padding-right: var(--clickable-area); - width: 300px; + width: 230px; } &__button { margin-left: -44px; From b3a9650c7c086a25a89de90ef87beced57ed377c Mon Sep 17 00:00:00 2001 From: Marco Ambrosini Date: Tue, 24 Mar 2020 08:09:54 +0100 Subject: [PATCH 3/3] Show renaming form only if current user is guest Signed-off-by: Marco Ambrosini --- src/components/LobbyScreen.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/LobbyScreen.vue b/src/components/LobbyScreen.vue index f0dd96e6359..f374a1d3024 100644 --- a/src/components/LobbyScreen.vue +++ b/src/components/LobbyScreen.vue @@ -25,7 +25,7 @@

{{ currentConversationName }}

{{ message }}

- + @@ -67,7 +67,10 @@ export default { return message }, - + // Determines whether the current user is a guest user + currentUserIsGuest() { + return !this.$store.getters.getUserId() + }, }, }