|
@@ -45500,11 +45500,11 @@ return __p
|
|
|
return model.collection && model.collection.browserStorage;
|
|
|
}
|
|
|
|
|
|
- utils.saveWithFallback = function (model, attrs) {
|
|
|
- if (utils.isPersistableModel(this)) {
|
|
|
- model.save(attrs);
|
|
|
+ utils.safeSave = function (model, attributes) {
|
|
|
+ if (utils.isPersistableModel(model)) {
|
|
|
+ model.save(attributes);
|
|
|
} else {
|
|
|
- model.set(attrs);
|
|
|
+ model.set(attributes);
|
|
|
}
|
|
|
}
|
|
|
return utils;
|
|
@@ -48927,13 +48927,15 @@ return Backbone.BrowserStorage;
|
|
|
};
|
|
|
|
|
|
this.logOut = function () {
|
|
|
+ _converse.chatboxviews.closeAllChatBoxes();
|
|
|
+ _converse.clearSession();
|
|
|
+
|
|
|
_converse.setDisconnectionCause(_converse.LOGOUT, undefined, true);
|
|
|
if (!_.isUndefined(_converse.connection)) {
|
|
|
_converse.connection.disconnect();
|
|
|
+ } else {
|
|
|
+ _converse._tearDown();
|
|
|
}
|
|
|
- _converse.chatboxviews.closeAllChatBoxes();
|
|
|
- _converse.clearSession();
|
|
|
- _converse._tearDown();
|
|
|
_converse.emit('logout');
|
|
|
};
|
|
|
|
|
@@ -50417,7 +50419,9 @@ return Backbone.BrowserStorage;
|
|
|
"Either when calling converse.initialize, or when calling " +
|
|
|
"_converse.api.user.login.");
|
|
|
}
|
|
|
- this.connection.reset();
|
|
|
+ if (!this.connection.reconnecting) {
|
|
|
+ this.connection.reset();
|
|
|
+ }
|
|
|
this.connection.connect(this.jid.toLowerCase(), null, this.onConnectStatusChanged);
|
|
|
} else if (this.authentication === _converse.LOGIN) {
|
|
|
var password = _.isNil(credentials) ? (_converse.connection.pass || this.password) : credentials.password;
|
|
@@ -50436,7 +50440,9 @@ return Backbone.BrowserStorage;
|
|
|
} else {
|
|
|
this.jid = Strophe.getBareJidFromJid(this.jid).toLowerCase()+'/'+resource;
|
|
|
}
|
|
|
- this.connection.reset();
|
|
|
+ if (!this.connection.reconnecting) {
|
|
|
+ this.connection.reset();
|
|
|
+ }
|
|
|
this.connection.connect(this.jid, password, this.onConnectStatusChanged);
|
|
|
}
|
|
|
};
|
|
@@ -51717,9 +51723,7 @@ return __p
|
|
|
},
|
|
|
|
|
|
afterShown: function (focus) {
|
|
|
- if (this.model.collection.browserStorage) {
|
|
|
- // Without a connection, we haven't yet initialized
|
|
|
- // localstorage
|
|
|
+ if (utils.isPersistableModel(this.model)) {
|
|
|
this.model.save();
|
|
|
}
|
|
|
this.setChatState(_converse.ACTIVE);
|
|
@@ -51780,7 +51784,7 @@ return __p
|
|
|
scrolled = false;
|
|
|
this.onScrolledDown();
|
|
|
}
|
|
|
- utils.saveWithFallback(this.model, {'scrolled': scrolled});
|
|
|
+ utils.safeSave(this.model, {'scrolled': scrolled});
|
|
|
}, 150),
|
|
|
|
|
|
viewUnreadMessages: function () {
|
|
@@ -55250,6 +55254,14 @@ define("awesomplete", (function (global) {
|
|
|
//
|
|
|
// New functions which don't exist yet can also be added.
|
|
|
|
|
|
+ _tearDown: function () {
|
|
|
+ var rooms = this.chatboxes.where({'type': CHATROOMS_TYPE});
|
|
|
+ _.each(rooms, function (room) {
|
|
|
+ utils.safeSave(room, {'connection_status': ROOMSTATUS.DISCONNECTED});
|
|
|
+ });
|
|
|
+ this.__super__._tearDown.call(this, arguments);
|
|
|
+ },
|
|
|
+
|
|
|
Features: {
|
|
|
addClientFeatures: function () {
|
|
|
var _converse = this.__super__._converse;
|
|
@@ -55527,7 +55539,7 @@ define("awesomplete", (function (global) {
|
|
|
},
|
|
|
|
|
|
clearUnreadMsgCounter: function() {
|
|
|
- utils.saveWithFallback(this, {
|
|
|
+ utils.safeSave(this, {
|
|
|
'num_unread': 0,
|
|
|
'num_unread_general': 0
|
|
|
});
|
|
@@ -56342,14 +56354,16 @@ define("awesomplete", (function (global) {
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
- cleanup: function () {
|
|
|
- if (this.model.collection && this.model.collection.browserStorage) {
|
|
|
- this.model.save('connection_status', ROOMSTATUS.DISCONNECTED);
|
|
|
- } else {
|
|
|
- this.model.set('connection_status', ROOMSTATUS.DISCONNECTED);
|
|
|
+ sendUnavailablePresence: function (exit_msg) {
|
|
|
+ var presence = $pres({
|
|
|
+ type: "unavailable",
|
|
|
+ from: _converse.connection.jid,
|
|
|
+ to: this.getRoomJIDAndNick()
|
|
|
+ });
|
|
|
+ if (exit_msg !== null) {
|
|
|
+ presence.c("status", exit_msg);
|
|
|
}
|
|
|
- this.removeHandlers();
|
|
|
- _converse.ChatBoxView.prototype.close.apply(this, arguments);
|
|
|
+ _converse.connection.sendPresence(presence);
|
|
|
},
|
|
|
|
|
|
leave: function(exit_msg) {
|
|
@@ -56362,26 +56376,15 @@ define("awesomplete", (function (global) {
|
|
|
this.hide();
|
|
|
this.occupantsview.model.reset();
|
|
|
this.occupantsview.model.browserStorage._clear();
|
|
|
- if (!_converse.connection.connected ||
|
|
|
- this.model.get('connection_status') === ROOMSTATUS.DISCONNECTED) {
|
|
|
- // Don't send out a stanza if we're not connected.
|
|
|
- this.cleanup();
|
|
|
- return;
|
|
|
- }
|
|
|
- var presence = $pres({
|
|
|
- type: "unavailable",
|
|
|
- from: _converse.connection.jid,
|
|
|
- to: this.getRoomJIDAndNick()
|
|
|
- });
|
|
|
- if (exit_msg !== null) {
|
|
|
- presence.c("status", exit_msg);
|
|
|
+ if (_converse.connection.connected) {
|
|
|
+ this.sendUnavailablePresence(exit_msg);
|
|
|
}
|
|
|
- _converse.connection.sendPresence(
|
|
|
- presence,
|
|
|
- this.cleanup.bind(this),
|
|
|
- this.cleanup.bind(this),
|
|
|
- 2000
|
|
|
+ utils.safeSave(
|
|
|
+ this.model,
|
|
|
+ {'connection_status': ROOMSTATUS.DISCONNECTED}
|
|
|
);
|
|
|
+ this.removeHandlers();
|
|
|
+ _converse.ChatBoxView.prototype.close.apply(this, arguments);
|
|
|
},
|
|
|
|
|
|
renderConfigurationForm: function (stanza) {
|
|
@@ -56392,7 +56395,8 @@ define("awesomplete", (function (global) {
|
|
|
* either submitted the form, or canceled it.
|
|
|
*
|
|
|
* Parameters:
|
|
|
- * (XMLElement) stanza: The IQ stanza containing the room config.
|
|
|
+ * (XMLElement) stanza: The IQ stanza containing the room
|
|
|
+ * config.
|
|
|
*/
|
|
|
var that = this,
|
|
|
$body = this.$('.chatroom-body');
|
|
@@ -57901,7 +57905,9 @@ define("awesomplete", (function (global) {
|
|
|
_converse.chatboxviews.each(function (view) {
|
|
|
if (view.model.get('type') === CHATROOMS_TYPE) {
|
|
|
view.model.save('connection_status', ROOMSTATUS.DISCONNECTED);
|
|
|
+ view.registerHandlers();
|
|
|
view.join();
|
|
|
+ view.fetchMessages();
|
|
|
}
|
|
|
});
|
|
|
};
|
|
@@ -68528,14 +68534,14 @@ return __p
|
|
|
},
|
|
|
|
|
|
maximize: function () {
|
|
|
- utils.saveWithFallback(this, {
|
|
|
+ utils.safeSave(this, {
|
|
|
'minimized': false,
|
|
|
'time_opened': moment().valueOf()
|
|
|
});
|
|
|
},
|
|
|
|
|
|
minimize: function () {
|
|
|
- utils.saveWithFallback(this, {
|
|
|
+ utils.safeSave(this, {
|
|
|
'minimized': true,
|
|
|
'time_minimized': moment().format()
|
|
|
});
|