Przeglądaj źródła

Override save on ChatBox to not persist the 'trimmed' attribute

JC Brand 11 lat temu
rodzic
commit
1a92db8946
1 zmienionych plików z 18 dodań i 0 usunięć
  1. 18 0
      converse.js

+ 18 - 0
converse.js

@@ -662,6 +662,24 @@
                 }
             },
 
+            save: function(key, val, options) {
+                /* Override the backbone function and exclude the 'trimmed'
+                 * attribute from being persisted.
+                 */
+                var attrs;
+                // Handle both `"key", value` and `{key: value}` -style arguments.
+                if (key == null || typeof key === 'object') {
+                    attrs = key;
+                    options = val;
+                } else {
+                    (attrs = {})[key] = val;
+                }
+                if (typeof attrs === 'object') {
+                    delete attrs.trimmed;
+                }
+                Backbone.Model.prototype.save.call(this, attrs, options);
+            },
+
             getSession: function (callback) {
                 var cipher = CryptoJS.lib.PasswordBasedCipher;
                 var result, pass, instance_tag, saved_key, pass_check;