|
@@ -29656,18 +29656,10 @@ return Backbone.BrowserStorage;
|
|
},
|
|
},
|
|
|
|
|
|
onChatBoxAdded: function (item) {
|
|
onChatBoxAdded: function (item) {
|
|
- var view = this.get(item.get('id'));
|
|
|
|
- // Views aren't created here, since the core code doesn't have
|
|
|
|
|
|
+ // Views aren't created here, since the core code doesn't
|
|
// contain any views. Instead, they're created in overrides in
|
|
// contain any views. Instead, they're created in overrides in
|
|
- // converse-chatiew.js and/or converse-muc.js
|
|
|
|
- if (view) {
|
|
|
|
- // This is an optimization. We don't remove older views, so
|
|
|
|
- // when one is available, we reuse it.
|
|
|
|
- delete view.model; // Remove ref to old model to help garbage collection
|
|
|
|
- view.model = item;
|
|
|
|
- view.initialize();
|
|
|
|
- }
|
|
|
|
- return view;
|
|
|
|
|
|
+ // plugins, such as in converse-chatview.js and converse-muc.js
|
|
|
|
+ return this.get(item.get('id'));
|
|
},
|
|
},
|
|
|
|
|
|
removeChat: function (item) {
|
|
removeChat: function (item) {
|
|
@@ -30143,8 +30135,13 @@ return Backbone.BrowserStorage;
|
|
'initialize': function (settings, callback) {
|
|
'initialize': function (settings, callback) {
|
|
converse.initialize(settings, callback);
|
|
converse.initialize(settings, callback);
|
|
},
|
|
},
|
|
- 'disconnect': function () {
|
|
|
|
- converse.connection.disconnect();
|
|
|
|
|
|
+ 'connection': {
|
|
|
|
+ 'connected': function () {
|
|
|
|
+ return converse.connection && converse.connection.connected || false;
|
|
|
|
+ },
|
|
|
|
+ 'disconnect': function () {
|
|
|
|
+ converse.connection.disconnect();
|
|
|
|
+ },
|
|
},
|
|
},
|
|
'user': {
|
|
'user': {
|
|
'logout': function () {
|
|
'logout': function () {
|
|
@@ -30273,7 +30270,7 @@ return Backbone.BrowserStorage;
|
|
converse.connection.addHandler(
|
|
converse.connection.addHandler(
|
|
handler,
|
|
handler,
|
|
options.ns,
|
|
options.ns,
|
|
- options.name,
|
|
|
|
|
|
+ name,
|
|
options.type,
|
|
options.type,
|
|
options.id,
|
|
options.id,
|
|
options.from,
|
|
options.from,
|
|
@@ -31581,6 +31578,7 @@ define('text!zh',[],function () { return '{\n "domain": "converse",\n "local
|
|
},
|
|
},
|
|
|
|
|
|
onScroll: function (ev) {
|
|
onScroll: function (ev) {
|
|
|
|
+ // XXX: This should go into converse-mam.js
|
|
if ($(ev.target).scrollTop() === 0 && this.model.messages.length) {
|
|
if ($(ev.target).scrollTop() === 0 && this.model.messages.length) {
|
|
this.fetchArchivedMessages({
|
|
this.fetchArchivedMessages({
|
|
'before': this.model.messages.at(0).get('archive_id'),
|
|
'before': this.model.messages.at(0).get('archive_id'),
|
|
@@ -31599,6 +31597,7 @@ define('text!zh',[],function () { return '{\n "domain": "converse",\n "local
|
|
this.model.messages.fetch({
|
|
this.model.messages.fetch({
|
|
'add': true,
|
|
'add': true,
|
|
'success': function () {
|
|
'success': function () {
|
|
|
|
+ // XXX: This should go into converse-mam.js
|
|
if (!converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
|
if (!converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -31620,6 +31619,7 @@ define('text!zh',[],function () { return '{\n "domain": "converse",\n "local
|
|
* Then, upon receiving them, call onMessage on the chat box,
|
|
* Then, upon receiving them, call onMessage on the chat box,
|
|
* so that they are displayed inside it.
|
|
* so that they are displayed inside it.
|
|
*/
|
|
*/
|
|
|
|
+ // XXX: This should go into converse-mam.js
|
|
if (!converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
|
if (!converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
|
converse.log("Attempted to fetch archived messages but this user's server doesn't support XEP-0313");
|
|
converse.log("Attempted to fetch archived messages but this user's server doesn't support XEP-0313");
|
|
return;
|
|
return;
|
|
@@ -34679,10 +34679,16 @@ Strophe.RSM.prototype = {
|
|
|
|
|
|
ChatBoxViews: {
|
|
ChatBoxViews: {
|
|
onChatBoxAdded: function (item) {
|
|
onChatBoxAdded: function (item) {
|
|
- var view = this.get(item.get('id'));
|
|
|
|
- if (!view && item.get('box_id') === 'controlbox') {
|
|
|
|
- view = new converse.ControlBoxView({model: item});
|
|
|
|
- return this.add(item.get('id'), view);
|
|
|
|
|
|
+ if (item.get('box_id') === 'controlbox') {
|
|
|
|
+ var view = this.get(item.get('id'));
|
|
|
|
+ if (view) {
|
|
|
|
+ view.model = item;
|
|
|
|
+ view.initialize();
|
|
|
|
+ return view;
|
|
|
|
+ } else {
|
|
|
|
+ view = new converse.ControlBoxView({model: item});
|
|
|
|
+ return this.add(item.get('id'), view);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
return this._super.onChatBoxAdded.apply(this, arguments);
|
|
return this._super.onChatBoxAdded.apply(this, arguments);
|
|
}
|
|
}
|
|
@@ -44778,10 +44784,6 @@ define("crypto.mode-ctr", ["crypto.cipher-core"], function(){});
|
|
return chatbox;
|
|
return chatbox;
|
|
},
|
|
},
|
|
|
|
|
|
- onChatBoxAdded: function (item) {
|
|
|
|
- this.trimChats(this._super.onChatBoxAdded.apply(this, arguments));
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
getChatBoxWidth: function (view) {
|
|
getChatBoxWidth: function (view) {
|
|
if (!view.model.get('minimized') && view.$el.is(':visible')) {
|
|
if (!view.model.get('minimized') && view.$el.is(':visible')) {
|
|
return view.$el.outerWidth(true);
|
|
return view.$el.outerWidth(true);
|
|
@@ -44789,6 +44791,12 @@ define("crypto.mode-ctr", ["crypto.cipher-core"], function(){});
|
|
return 0;
|
|
return 0;
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ getShownChats: function () {
|
|
|
|
+ return this.filter(function (view) {
|
|
|
|
+ return (!view.model.get('minimized') && view.$el.is(':visible'));
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
trimChats: function (newchat) {
|
|
trimChats: function (newchat) {
|
|
/* This method is called when a newly created chat box will
|
|
/* This method is called when a newly created chat box will
|
|
* be shown.
|
|
* be shown.
|
|
@@ -44797,7 +44805,14 @@ define("crypto.mode-ctr", ["crypto.cipher-core"], function(){});
|
|
* another chat box. Otherwise it minimizes the oldest chat box
|
|
* another chat box. Otherwise it minimizes the oldest chat box
|
|
* to create space.
|
|
* to create space.
|
|
*/
|
|
*/
|
|
- if (converse.no_trimming || (this.model.length <= 1)) {
|
|
|
|
|
|
+ var shown_chats = this.getShownChats();
|
|
|
|
+ if (converse.no_trimming || shown_chats.length <= 1) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.getChatBoxWidth(shown_chats[0]) === $('body').outerWidth(true)) {
|
|
|
|
+ // If the chats shown are the same width as the body,
|
|
|
|
+ // then we're in responsive mode and the chats are
|
|
|
|
+ // fullscreen. In this case we don't trim.
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var oldest_chat, boxes_width, view,
|
|
var oldest_chat, boxes_width, view,
|
|
@@ -44953,7 +44968,7 @@ define("crypto.mode-ctr", ["crypto.cipher-core"], function(){});
|
|
render: function () {
|
|
render: function () {
|
|
if (this.keys().length === 0) {
|
|
if (this.keys().length === 0) {
|
|
this.$el.hide('fast', converse.chatboxviews.trimChats.bind(converse.chatboxviews));
|
|
this.$el.hide('fast', converse.chatboxviews.trimChats.bind(converse.chatboxviews));
|
|
- } else if (this.keys().length === 1) {
|
|
|
|
|
|
+ } else if (this.keys().length === 1 && !this.$el.is(':visible')) {
|
|
this.$el.show('fast', converse.chatboxviews.trimChats.bind(converse.chatboxviews));
|
|
this.$el.show('fast', converse.chatboxviews.trimChats.bind(converse.chatboxviews));
|
|
}
|
|
}
|
|
return this.$el;
|
|
return this.$el;
|