Bläddra i källkod

Add new configuration variable: `default_state`

JC Brand 9 år sedan
förälder
incheckning
f70a3c3ed2
3 ändrade filer med 16 tillägg och 7 borttagningar
  1. 3 4
      docs/CHANGES.md
  2. 9 0
      docs/source/configuration.rst
  3. 4 3
      src/converse-core.js

+ 3 - 4
docs/CHANGES.md

@@ -2,15 +2,14 @@
 
 ## 1.0.3 (Unreleased)
 
-- Bugfix. Login form doesn't render after logging out, when `auto_reconnect = false`
-[jcbrand]
+- Bugfix. Login form doesn't render after logging out, when `auto_reconnect = false` [jcbrand]
 - Also indicate new day for the first day's messages. [jcbrand]
-- Chat bot messages don't appear when they have the same ids as their commands.
-  [jcbrand]
+- Chat bot messages don't appear when they have the same ids as their commands. [jcbrand]
 - Updated onDisconnected method to fire disconnected event even if `auto_reconnect = false`. [kamranzafar]
 - Bugfix: MAM messages weren't being fetched oldest first. [jcbrand]
 - Add processing hints to chat state notifications [jcbrand]
 - Don't use sound and desktop notifications for OTR messages (when setting up the session) [jcbrand]
+- New config option [default_state](https://conversejs.org/docs/html/configuration.html#default_state) [jcbrand]
 - #553 Add processing hints to OTR messages [jcbrand]
 - #650 Don't ignore incoming messages with same JID as current user (might be MAM archived) [jcbrand]
 

+ 9 - 0
docs/source/configuration.rst

@@ -395,6 +395,15 @@ JIDs with other domains are still allowed but need to be provided in full.
 To specify only one domain and disallow other domains, see the `locked_domain`_
 option.
 
+default_state
+-------------
+
+* Default: ``'online'``
+
+The default chat status that the user wil have. If you for example set this to
+``'chat'``, then converse.js will send out a presence stanza with ``"show"``
+set to ``'chat'`` as soon as you've been logged in.
+
 domain_placeholder
 ------------------
 

+ 4 - 3
src/converse-core.js

@@ -259,6 +259,7 @@
             credentials_url: null, // URL from where login credentials can be fetched
             csi_waiting_time: 0, // Support for XEP-0352. Seconds before client is considered idle and CSI is sent out.
             debug: false,
+            default_state: 'online',
             expose_rid_and_sid: false,
             filter_by_resource: false,
             forward_messages: false,
@@ -357,7 +358,7 @@
             }
             if (converse.auto_changed_status === true) {
                 converse.auto_changed_status = false;
-                converse.xmppstatus.setStatus('online');
+                converse.xmppstatus.setStatus(converse.default_state);
             }
         };
 
@@ -1431,7 +1432,7 @@
 
             constructPresence: function (type, status_message) {
                 if (typeof type !== 'string') {
-                    type = this.get('status') || 'online';
+                    type = this.get('status') || converse.default_state;
                 }
                 if (typeof status_message !== 'string') {
                     status_message = this.get('status_message');
@@ -1475,7 +1476,7 @@
             },
 
             getStatus: function () {
-                return this.get('status') || 'online';
+                return this.get('status') || converse.default_state;
             },
 
             setStatusMessage: function (status_message) {