Răsfoiți Sursa

In case of a nickname conflict, enable the user to choose a new one

JC Brand 9 ani în urmă
părinte
comite
be47ceaab5

+ 3 - 0
css/converse.css

@@ -2061,6 +2061,9 @@
         height: calc(100% - 55px);
         overflow-y: auto;
         position: absolute; }
+        #conversejs .chatroom .box-flyout .chatroom-body .chatroom-form-container .validation-message {
+          font-size: 90%;
+          color: #D24E2B; }
   #conversejs .chatroom .chat-textarea {
     border-bottom-right-radius: 0; }
   #conversejs .chatroom .room-invite {

+ 7 - 4
docs/CHANGES.md

@@ -1,16 +1,19 @@
 # Changelog
 
+## 1.0.5 (Unreleased)
+- In case of a nickname conflict when joining a room, allow the user to choose a new nickname. [jcbrand]
+- Check whether the user has a reserved nickname before entering a room, and if so, use it. [jcbrand]
+
 ## 1.0.4 (2016-07-26)
 
 - Restrict occupants sidebar to 30% chatroom width. [jcbrand]
 - Made requesting contacts more visible, by placing them at the top of the roster. [jcbrand]
 - `insertIntoPage` method of `ChatBoxView` has been renamed to `insertIntoDOM`,
   to make it the same as the method of `ChatRoomView`. [jcbrand]
-- Render error messages received from the server (for undelivered chat
-  messages). [jcbrand]
+- Render error messages received from the server (for undelivered chat messages). [jcbrand]
 - Don't hide requesting contacts when filtering by chat state. [jcbrand]
-- When logging in anonymously, the server JID can now be passed in via
-  `converse.initialize` or via `converse.user.login`. [jcbrand]
+- When logging in anonymously, the server JID can now be passed in via `converse.initialize`
+  or via `converse.user.login`. [jcbrand]
 
 ## 1.0.3 (2016-06-20)
 

+ 5 - 0
sass/_chatrooms.scss

@@ -130,6 +130,11 @@
                     @include calc(height, '100% - #{$chat-head-height}');
                     overflow-y: auto;
                     position: absolute;
+
+                    .validation-message {
+                        font-size: 90%;
+                        color: $error-color;
+                    }
                 }
             }
         }

+ 2 - 0
sass/_variables.scss

@@ -40,6 +40,8 @@ $toolbar-color: #FFF5EE !default;
 $moderator-color: #D24E2B !default;
 $online-color: #1A9707 !default;
 
+$error-color: #D24E2B !default;
+
 $chatbox-border-radius: 4px !default;
 $bottom-gutter-height: 35px !default;
 $chatbox-hover-height: 6px !default;

+ 2 - 1
spec/chatroom.js

@@ -899,7 +899,8 @@
                 var view = this.chatboxviews.get('problematic@muc.localhost');
                 spyOn(view, 'showErrorMessage').andCallThrough();
                 view.onChatRoomPresence(presence, {'nick': 'dummy'});
-                expect(view.$el.find('.chatroom-body p:last').text()).toBe("Your nickname is already taken");
+                expect(view.$el.find('.chatroom-body p:last').text()).toBe(
+                        "The nickname you chose is reserved or currently in use, please choose a different one.");
             }.bind(converse));
 
             it("will show an error message if the room doesn't yet exist", function () {

+ 7 - 4
src/converse-muc.js

@@ -780,14 +780,18 @@
                     }
                 },
 
-                renderNicknameForm: function () {
+                renderNicknameForm: function (message) {
                     this.$('.chatroom-body').children().addClass('hidden');
                     this.$('span.centered.spinner').remove();
+                    if (typeof message !== "string") {
+                        message = '';
+                    }
                     this.$('.chatroom-body').append(
                         converse.templates.chatroom_nickname_form({
                             heading: __('Please choose your nickname'),
                             label_nickname: __('Nickname'),
-                            label_join: __('Enter room')
+                            label_join: __('Enter room'),
+                            validation_message: message
                         }));
                     this.$('.chatroom-form').on('submit', this.submitNickname.bind(this));
                 },
@@ -966,8 +970,7 @@
                         } else if ($error.find('not-acceptable').length) {
                             this.showDisconnectMessage(__("Your nickname doesn't conform to this room's policies"));
                         } else if ($error.find('conflict').length) {
-                            this.showDisconnectMessage(__("Your nickname is already taken"));
-                            // TODO: give user the option of choosing a different nickname
+                            this.renderNicknameForm(__("The nickname you chose is reserved or currently in use, please choose a different one."));
                         } else if ($error.find('item-not-found').length) {
                             this.showDisconnectMessage(__("This room does not (yet) exist"));
                         } else if ($error.find('service-unavailable').length) {

+ 1 - 0
src/templates/chatroom_nickname_form.html

@@ -2,6 +2,7 @@
     <form class="pure-form converse-form chatroom-form">
         <fieldset>
             <label>{{heading}}</label>
+            <p class="validation-message">{{validation_message}}</p>
             <input type="text" required="required" name="nick" class="new-chatroom-nick" placeholder="{{label_nickname}}"/>
         </fieldset>
         <fieldset>