Browse Source

add synchronize_availability option

Davide Colombo 9 years ago
parent
commit
e934917685
3 changed files with 19 additions and 2 deletions
  1. 1 0
      docs/CHANGES.md
  2. 15 0
      docs/source/configuration.rst
  3. 3 2
      src/converse-core.js

+ 1 - 0
docs/CHANGES.md

@@ -14,6 +14,7 @@
 - #587 Fix issue when logging out with `auto_logout=true` [davec82]
 - #589 Save scroll position on minimize and restore it on maximize [rlanvin]
 - #592 Add random resource for `auto_login`, add method generateResource to generate random resource [davec82]
+- #598 Add option `synchronize_availability` [davec82]
 
 ## 0.10.1 (2016-02-06)
 

+ 15 - 0
docs/source/configuration.rst

@@ -679,6 +679,21 @@ Data in localStorage on the other hand is kept indefinitely.
     roster contact statuses will not become out of sync in a single session,
     only across more than one session.
 
+synchronize_availability
+--------------------
+
+* Default: ``true``
+
+Valid options: ``true``, ``false``, ``a resource name``.
+
+This option lets you synchronize your chat status (`online`, `busy`, `away`) with other chat clients. In other words,
+if you change your status to `busy` in a different chat client, your status will change to `busy` in converse.js as well.
+
+If set to ``true``, converse.js will synchronize with all other clients you are logged in with.
+
+If set to ``false``, this feature is disabled.
+
+If set to ``a resource name``, converse.js will synchronize only with a client that has that particular resource assigned to it.
 
 use_otr_by_default
 ------------------

+ 3 - 2
src/converse-core.js

@@ -335,6 +335,7 @@
             sid: undefined,
             sounds_path: '/sounds/',
             storage: 'session',
+            synchronize_availability: true, // Set to false to not sync with other clients or with resource name of the particular client that it should synchronize with
             use_vcards: true,
             visible_toolbar_buttons: {
                 'emoticons': true,
@@ -3310,8 +3311,8 @@
                     status_message = $presence.find('status'),
                     contact = this.get(bare_jid);
                 if (this.isSelf(bare_jid)) {
-                    if ((converse.connection.jid !== jid)&&(presence_type !== 'unavailable')) {
-                        // Another resource has changed its status, we'll update ours as well.
+                    if ((converse.connection.jid !== jid)&&(presence_type !== 'unavailable')&&(converse.synchronize_availability === true || converse.synchronize_availability === resource)) {
+                        // Another resource has changed its status and synchronize_availability option let to update, we'll update ours as well.
                         converse.xmppstatus.save({'status': chat_status});
                         if (status_message.length) { converse.xmppstatus.save({'status_message': status_message.text()}); }
                     }