Commit b8765008 authored by JC Brand's avatar JC Brand

Update to latest backbone.overview

parent 7032ded5
...@@ -2419,12 +2419,11 @@ ...@@ -2419,12 +2419,11 @@
"dev": true "dev": true
}, },
"backbone.overview": { "backbone.overview": {
"version": "1.0.2", "version": "github:jcbrand/Backbone.Overview#b3e759127d859c90e8e21700a9a5714a3b828f0a",
"resolved": "https://registry.npmjs.org/backbone.overview/-/backbone.overview-1.0.2.tgz", "from": "github:jcbrand/Backbone.Overview#b3e759127d859c90e8e21700a9a5714a3b828f0a",
"integrity": "sha512-NQMvi4H2h25QKKFiweK1aK1IPPv7MbcUMpKJkUAZdjE1gRgFlSwDiw+Y2vnwDFayKaWmnRoSqf/MDIxjFhLcNQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"backbone": "^1.3.3" "lodash": "^4.17.11"
} }
}, },
"backbone.vdomview": { "backbone.vdomview": {
...@@ -2570,9 +2569,41 @@ ...@@ -2570,9 +2569,41 @@
"dev": true "dev": true
}, },
"bootstrap.native-loader": { "bootstrap.native-loader": {
"version": "github:conversejs/bootstrap.native-loader#d8fcbc059562136ffd50b305fdc6eb2bde90f006", "version": "2.0.0",
"from": "github:conversejs/bootstrap.native-loader#d8fcbc059562136ffd50b305fdc6eb2bde90f006", "resolved": "https://registry.npmjs.org/bootstrap.native-loader/-/bootstrap.native-loader-2.0.0.tgz",
"dev": true "integrity": "sha512-Olau+W5+mPotQJ5BCfIiP/SWQd8/zXqnTwhrTiyViciMvqBI+RgmtJD5aHOKhdBnHz5H1korn7Pf2s4dhAZ1RA==",
"dev": true,
"requires": {
"loader-utils": "^1.2.3"
},
"dependencies": {
"big.js": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
"integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==",
"dev": true
},
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
}
},
"loader-utils": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz",
"integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^2.0.0",
"json5": "^1.0.1"
}
}
}
}, },
"bourbon": { "bourbon": {
"version": "4.3.4", "version": "4.3.4",
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
* in XEP-0048. * in XEP-0048.
*/ */
import "backbone.nativeview";
import BrowserStorage from "backbone.browserStorage";
import { OrderedListView } from "backbone.overview";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import muc from "@converse/headless/converse-muc"; import muc from "@converse/headless/converse-muc";
import tpl_bookmark from "templates/bookmark.html"; import tpl_bookmark from "templates/bookmark.html";
...@@ -254,7 +257,7 @@ converse.plugins.add('converse-bookmark-views', { ...@@ -254,7 +257,7 @@ converse.plugins.add('converse-bookmark-views', {
}); });
_converse.BookmarksView = Backbone.OrderedListView.extend({ _converse.BookmarksView = OrderedListView.extend({
tagName: 'div', tagName: 'div',
className: 'bookmarks-list list-container rooms-list-container', className: 'bookmarks-list list-container rooms-list-container',
events: { events: {
...@@ -268,7 +271,7 @@ converse.plugins.add('converse-bookmark-views', { ...@@ -268,7 +271,7 @@ converse.plugins.add('converse-bookmark-views', {
subviewIndex: 'jid', subviewIndex: 'jid',
initialize () { initialize () {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
this.model.on('add', this.showOrHide, this); this.model.on('add', this.showOrHide, this);
this.model.on('remove', this.showOrHide, this); this.model.on('remove', this.showOrHide, this);
...@@ -279,7 +282,7 @@ converse.plugins.add('converse-bookmark-views', { ...@@ -279,7 +282,7 @@ converse.plugins.add('converse-bookmark-views', {
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = `converse.room-bookmarks${_converse.bare_jid}-list-model`; id = `converse.room-bookmarks${_converse.bare_jid}-list-model`;
this.list_model = new _converse.BookmarksList({'id': id}); this.list_model = new _converse.BookmarksList({'id': id});
this.list_model.browserStorage = new Backbone.BrowserStorage[storage](id); this.list_model.browserStorage = new BrowserStorage[storage](id);
const render = () => { const render = () => {
this.render(); this.render();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import "@converse/headless/converse-chatboxes"; import "@converse/headless/converse-chatboxes";
import "backbone.nativeview"; import "backbone.nativeview";
import "backbone.overview"; import { Overview } from "backbone.overview";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import tpl_avatar from "templates/avatar.svg"; import tpl_avatar from "templates/avatar.svg";
import tpl_background_logo from "templates/background_logo.html"; import tpl_background_logo from "templates/background_logo.html";
...@@ -79,7 +79,7 @@ converse.plugins.add('converse-chatboxviews', { ...@@ -79,7 +79,7 @@ converse.plugins.add('converse-chatboxviews', {
_converse.VDOMViewWithAvatar = Backbone.VDOMView.extend(AvatarMixin); _converse.VDOMViewWithAvatar = Backbone.VDOMView.extend(AvatarMixin);
_converse.ChatBoxViews = Backbone.Overview.extend({ _converse.ChatBoxViews = Overview.extend({
_ensureElement () { _ensureElement () {
/* Override method from backbone.js /* Override method from backbone.js
...@@ -143,7 +143,7 @@ converse.plugins.add('converse-chatboxviews', { ...@@ -143,7 +143,7 @@ converse.plugins.add('converse-chatboxviews', {
/* This method gets overridden in src/converse-controlbox.js if /* This method gets overridden in src/converse-controlbox.js if
* the controlbox plugin is active. * the controlbox plugin is active.
*/ */
this.each(v => v.close()); this.forEach(v => v.close());
return this; return this;
} }
}); });
......
...@@ -4,10 +4,13 @@ ...@@ -4,10 +4,13 @@
// Copyright (c) 2013-2019, the Converse.js developers // Copyright (c) 2013-2019, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
import "backbone.nativeview";
import "converse-chatboxviews"; import "converse-chatboxviews";
import "converse-message-view"; import "converse-message-view";
import "converse-modal"; import "converse-modal";
import * as twemoji from "twemoji"; import * as twemoji from "twemoji";
import BrowserStorage from "backbone.browserStorage";
import { Overview } from "backbone.overview";
import bootstrap from "bootstrap.native"; import bootstrap from "bootstrap.native";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import tpl_alert from "templates/alert.html"; import tpl_alert from "templates/alert.html";
...@@ -69,7 +72,7 @@ converse.plugins.add('converse-chatview', { ...@@ -69,7 +72,7 @@ converse.plugins.add('converse-chatview', {
function onWindowStateChanged (data) { function onWindowStateChanged (data) {
if (_converse.chatboxviews) { if (_converse.chatboxviews) {
_converse.chatboxviews.each(view => { _converse.chatboxviews.forEach(view => {
if (view.model.get('id') !== 'controlbox') { if (view.model.get('id') !== 'controlbox') {
view.onWindowStateChanged(data.state); view.onWindowStateChanged(data.state);
} }
...@@ -309,7 +312,7 @@ converse.plugins.add('converse-chatview', { ...@@ -309,7 +312,7 @@ converse.plugins.add('converse-chatview', {
* @namespace _converse.ChatBoxView * @namespace _converse.ChatBoxView
* @memberOf _converse * @memberOf _converse
*/ */
_converse.ChatBoxView = Backbone.Overview.extend({ _converse.ChatBoxView = Overview.extend({
length: 200, length: 200,
className: 'chatbox hidden', className: 'chatbox hidden',
is_chatroom: false, // Leaky abstraction from MUC is_chatroom: false, // Leaky abstraction from MUC
...@@ -1107,7 +1110,7 @@ converse.plugins.add('converse-chatview', { ...@@ -1107,7 +1110,7 @@ converse.plugins.add('converse-chatview', {
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = `converse.emoji-${_converse.bare_jid}`; id = `converse.emoji-${_converse.bare_jid}`;
_converse.emojipicker = new _converse.EmojiPicker({'id': id}); _converse.emojipicker = new _converse.EmojiPicker({'id': id});
_converse.emojipicker.browserStorage = new Backbone.BrowserStorage[storage](id); _converse.emojipicker.browserStorage = new BrowserStorage[storage](id);
_converse.emojipicker.fetch(); _converse.emojipicker.fetch();
} }
this.emoji_picker_view = new _converse.EmojiPickerView({ this.emoji_picker_view = new _converse.EmojiPickerView({
......
...@@ -97,7 +97,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -97,7 +97,7 @@ converse.plugins.add('converse-controlbox', {
ChatBoxViews: { ChatBoxViews: {
closeAllChatBoxes () { closeAllChatBoxes () {
const { _converse } = this.__super__; const { _converse } = this.__super__;
this.each(function (view) { this.forEach(function (view) {
if (view.model.get('id') === 'controlbox' && if (view.model.get('id') === 'controlbox' &&
(_converse.disconnection_cause !== _converse.LOGOUT || _converse.show_controlbox_by_default)) { (_converse.disconnection_cause !== _converse.LOGOUT || _converse.show_controlbox_by_default)) {
return; return;
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
import "converse-chatview"; import "converse-chatview";
import BrowserStorage from "backbone.browserStorage";
import { Overview } from "backbone.overview";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import tpl_chatbox_minimize from "templates/chatbox_minimize.html"; import tpl_chatbox_minimize from "templates/chatbox_minimize.html";
import tpl_chats_panel from "templates/chats_panel.html"; import tpl_chats_panel from "templates/chats_panel.html";
...@@ -387,7 +389,7 @@ converse.plugins.add('converse-minimize', { ...@@ -387,7 +389,7 @@ converse.plugins.add('converse-minimize', {
}); });
_converse.MinimizedChats = Backbone.Overview.extend({ _converse.MinimizedChats = Overview.extend({
tagName: 'div', tagName: 'div',
id: "minimized-chats", id: "minimized-chats",
className: 'hidden', className: 'hidden',
...@@ -433,7 +435,7 @@ converse.plugins.add('converse-minimize', { ...@@ -433,7 +435,7 @@ converse.plugins.add('converse-minimize', {
this.toggleview = new _converse.MinimizedChatsToggleView({ this.toggleview = new _converse.MinimizedChatsToggleView({
'model': new _converse.MinimizedChatsToggle({'id': id}) 'model': new _converse.MinimizedChatsToggle({'id': id})
}); });
this.toggleview.model.browserStorage = new Backbone.BrowserStorage[storage](id); this.toggleview.model.browserStorage = new BrowserStorage[storage](id);
this.toggleview.model.fetch(); this.toggleview.model.fetch();
}, },
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
// XEP-0045 Multi-User Chat Views // XEP-0045 Multi-User Chat Views
import "converse-modal"; import "converse-modal";
import "backbone.overview/backbone.orderedlistview";
import "backbone.overview/backbone.overview";
import "backbone.vdomview"; import "backbone.vdomview";
import BrowserStorage from "backbone.browserStorage";
import { OrderedListView } from "backbone.overview";
import _FormData from "formdata-polyfill"; import _FormData from "formdata-polyfill";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import muc_utils from "@converse/headless/utils/muc"; import muc_utils from "@converse/headless/utils/muc";
...@@ -73,7 +73,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -73,7 +73,7 @@ converse.plugins.add('converse-muc-views', {
this.roomspanel = new _converse.RoomsPanel({ this.roomspanel = new _converse.RoomsPanel({
'model': new (_converse.RoomsPanelModel.extend({ 'model': new (_converse.RoomsPanelModel.extend({
'id': `converse.roomspanel${_converse.bare_jid}`, // Required by web storage 'id': `converse.roomspanel${_converse.bare_jid}`, // Required by web storage
'browserStorage': new Backbone.BrowserStorage[_converse.config.get('storage')]( 'browserStorage': new BrowserStorage[_converse.config.get('storage')](
`converse.roomspanel${_converse.bare_jid}`) `converse.roomspanel${_converse.bare_jid}`)
}))() }))()
}); });
...@@ -1950,7 +1950,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -1950,7 +1950,7 @@ converse.plugins.add('converse-muc-views', {
}); });
_converse.ChatRoomOccupantsView = Backbone.OrderedListView.extend({ _converse.ChatRoomOccupantsView = OrderedListView.extend({
tagName: 'div', tagName: 'div',
className: 'occupants col-md-3 col-4', className: 'occupants col-md-3 col-4',
listItems: 'model', listItems: 'model',
...@@ -1960,7 +1960,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -1960,7 +1960,7 @@ converse.plugins.add('converse-muc-views', {
ItemView: _converse.ChatRoomOccupantView, ItemView: _converse.ChatRoomOccupantView,
async initialize () { async initialize () {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
this.chatroomview = this.model.chatroomview; this.chatroomview = this.model.chatroomview;
this.chatroomview.model.features.on('change', this.renderRoomFeatures, this); this.chatroomview.model.features.on('change', this.renderRoomFeatures, this);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
/* global libsignal, ArrayBuffer, parseInt, crypto */ /* global libsignal, ArrayBuffer, parseInt, crypto */
import BrowserStorage from "backbone.browserStorage";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import tpl_toolbar_omemo from "templates/toolbar_omemo.html"; import tpl_toolbar_omemo from "templates/toolbar_omemo.html";
...@@ -966,7 +967,7 @@ converse.plugins.add('converse-omemo', { ...@@ -966,7 +967,7 @@ converse.plugins.add('converse-omemo', {
this.devices = new _converse.Devices(); this.devices = new _converse.Devices();
const id = `converse.devicelist-${_converse.bare_jid}-${this.get('jid')}`; const id = `converse.devicelist-${_converse.bare_jid}-${this.get('jid')}`;
const storage = _converse.config.get('storage'); const storage = _converse.config.get('storage');
this.devices.browserStorage = new Backbone.BrowserStorage[storage](id); this.devices.browserStorage = new BrowserStorage[storage](id);
this.fetchDevices(); this.fetchDevices();
}, },
...@@ -1151,7 +1152,7 @@ converse.plugins.add('converse-omemo', { ...@@ -1151,7 +1152,7 @@ converse.plugins.add('converse-omemo', {
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = `converse.omemosession-${_converse.bare_jid}`; id = `converse.omemosession-${_converse.bare_jid}`;
_converse.omemo_store = new _converse.OMEMOStore({'id': id}); _converse.omemo_store = new _converse.OMEMOStore({'id': id});
_converse.omemo_store.browserStorage = new Backbone.BrowserStorage[storage](id); _converse.omemo_store.browserStorage = new BrowserStorage[storage](id);
} }
return _converse.omemo_store.fetchSession(); return _converse.omemo_store.fetchSession();
} }
...@@ -1163,7 +1164,7 @@ converse.plugins.add('converse-omemo', { ...@@ -1163,7 +1164,7 @@ converse.plugins.add('converse-omemo', {
_converse.devicelists = new _converse.DeviceLists(); _converse.devicelists = new _converse.DeviceLists();
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = `converse.devicelists-${_converse.bare_jid}`; id = `converse.devicelists-${_converse.bare_jid}`;
_converse.devicelists.browserStorage = new Backbone.BrowserStorage[storage](id); _converse.devicelists.browserStorage = new BrowserStorage[storage](id);
try { try {
await fetchOwnDevices(); await fetchOwnDevices();
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
/* This is a non-core Converse.js plugin which shows a list of currently open /* This is a non-core Converse.js plugin which shows a list of currently open
* rooms in the "Rooms Panel" of the ControlBox. * rooms in the "Rooms Panel" of the ControlBox.
*/ */
import BrowserStorage from "backbone.browserStorage";
import { OrderedListView } from "backbone.overview";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import muc from "@converse/headless/converse-muc"; import muc from "@converse/headless/converse-muc";
import tpl_rooms_list from "templates/rooms_list.html"; import tpl_rooms_list from "templates/rooms_list.html";
...@@ -149,7 +150,7 @@ converse.plugins.add('converse-roomslist', { ...@@ -149,7 +150,7 @@ converse.plugins.add('converse-roomslist', {
}); });
_converse.RoomsListView = Backbone.OrderedListView.extend({ _converse.RoomsListView = OrderedListView.extend({
tagName: 'div', tagName: 'div',
className: 'open-rooms-list list-container rooms-list-container', className: 'open-rooms-list list-container rooms-list-container',
events: { events: {
...@@ -164,7 +165,7 @@ converse.plugins.add('converse-roomslist', { ...@@ -164,7 +165,7 @@ converse.plugins.add('converse-roomslist', {
subviewIndex: 'jid', subviewIndex: 'jid',
initialize () { initialize () {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
this.model.on('add', this.showOrHide, this); this.model.on('add', this.showOrHide, this);
this.model.on('remove', this.showOrHide, this); this.model.on('remove', this.showOrHide, this);
...@@ -173,7 +174,7 @@ converse.plugins.add('converse-roomslist', { ...@@ -173,7 +174,7 @@ converse.plugins.add('converse-roomslist', {
id = `converse.roomslist${_converse.bare_jid}`; id = `converse.roomslist${_converse.bare_jid}`;
this.list_model = new _converse.RoomsList({'id': id}); this.list_model = new _converse.RoomsList({'id': id});
this.list_model.browserStorage = new Backbone.BrowserStorage[storage](id); this.list_model.browserStorage = new BrowserStorage[storage](id);
this.list_model.fetch(); this.list_model.fetch();
this.render(); this.render();
this.sortAndPositionAllItems(); this.sortAndPositionAllItems();
...@@ -268,7 +269,7 @@ converse.plugins.add('converse-roomslist', { ...@@ -268,7 +269,7 @@ converse.plugins.add('converse-roomslist', {
id = `converse.open-rooms-{_converse.bare_jid}`, id = `converse.open-rooms-{_converse.bare_jid}`,
model = new _converse.OpenRooms(); model = new _converse.OpenRooms();
model.browserStorage = new Backbone.BrowserStorage[storage](id); model.browserStorage = new BrowserStorage[storage](id);
_converse.rooms_list_view = new _converse.RoomsListView({'model': model}); _converse.rooms_list_view = new _converse.RoomsListView({'model': model});
/** /**
* Triggered once the _converse.RoomsListView has been created and initialized. * Triggered once the _converse.RoomsListView has been created and initialized.
......
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
// Copyright (c) 2013-2019, the Converse.js developers // Copyright (c) 2013-2019, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
import "@converse/headless/converse-roster";
import "@converse/headless/converse-chatboxes"; import "@converse/headless/converse-chatboxes";
import "@converse/headless/converse-roster";
import "converse-modal"; import "converse-modal";
import BrowserStorage from "backbone.browserStorage";
import { OrderedListView } from "backbone.overview";
import _FormData from "formdata-polyfill"; import _FormData from "formdata-polyfill";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import tpl_add_contact_modal from "templates/add_contact_modal.html"; import tpl_add_contact_modal from "templates/add_contact_modal.html";
...@@ -18,6 +20,7 @@ import tpl_roster_filter from "templates/roster_filter.html"; ...@@ -18,6 +20,7 @@ import tpl_roster_filter from "templates/roster_filter.html";
import tpl_roster_item from "templates/roster_item.html"; import tpl_roster_item from "templates/roster_item.html";
import tpl_search_contact from "templates/search_contact.html"; import tpl_search_contact from "templates/search_contact.html";
const { Backbone, Strophe, $iq, b64_sha1, sizzle, _ } = converse.env; const { Backbone, Strophe, $iq, b64_sha1, sizzle, _ } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
...@@ -585,7 +588,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -585,7 +588,7 @@ converse.plugins.add('converse-rosterview', {
} }
}); });
_converse.RosterGroupView = Backbone.OrderedListView.extend({ _converse.RosterGroupView = OrderedListView.extend({
tagName: 'div', tagName: 'div',
className: 'roster-group hidden', className: 'roster-group hidden',
events: { events: {
...@@ -598,7 +601,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -598,7 +601,7 @@ converse.plugins.add('converse-rosterview', {
sortEvent: 'presenceChanged', sortEvent: 'presenceChanged',
initialize () { initialize () {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
this.model.contacts.on("change:subscription", this.onContactSubscriptionChange, this); this.model.contacts.on("change:subscription", this.onContactSubscriptionChange, this);
this.model.contacts.on("change:requesting", this.onContactRequestChange, this); this.model.contacts.on("change:requesting", this.onContactRequestChange, this);
this.model.contacts.on("remove", this.onRemove, this); this.model.contacts.on("remove", this.onRemove, this);
...@@ -772,7 +775,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -772,7 +775,7 @@ converse.plugins.add('converse-rosterview', {
}); });
_converse.RosterView = Backbone.OrderedListView.extend({ _converse.RosterView = OrderedListView.extend({
tagName: 'div', tagName: 'div',
id: 'converse-roster', id: 'converse-roster',
className: 'controlbox-section', className: 'controlbox-section',
...@@ -789,7 +792,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -789,7 +792,7 @@ converse.plugins.add('converse-rosterview', {
}, },
initialize () { initialize () {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
_converse.roster.on("add", this.onContactAdded, this); _converse.roster.on("add", this.onContactAdded, this);
_converse.roster.on('change:groups', this.onContactAdded, this); _converse.roster.on('change:groups', this.onContactAdded, this);
...@@ -842,7 +845,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -842,7 +845,7 @@ converse.plugins.add('converse-rosterview', {
// Create a model on which we can store filter properties // Create a model on which we can store filter properties
const model = new _converse.RosterFilter(); const model = new _converse.RosterFilter();
model.id = `_converse.rosterfilter${_converse.bare_jid}`; model.id = `_converse.rosterfilter${_converse.bare_jid}`;
model.browserStorage = new Backbone.BrowserStorage.local(this.filter.id); model.browserStorage = new BrowserStorage.local(this.filter.id);
this.filter_view = new _converse.RosterFilterView({'model': model}); this.filter_view = new _converse.RosterFilterView({'model': model});
this.filter_view.model.on('change', this.updateFilter, this); this.filter_view.model.on('change', this.updateFilter, this);
this.filter_view.model.fetch(); this.filter_view.model.fetch();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
* in XEP-0048. * in XEP-0048.
*/ */
import BrowserStorage from "backbone.browserStorage";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
import muc from "@converse/headless/converse-muc"; import muc from "@converse/headless/converse-muc";
...@@ -97,7 +98,7 @@ converse.plugins.add('converse-bookmarks', { ...@@ -97,7 +98,7 @@ converse.plugins.add('converse-bookmarks', {
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
cache_key = `converse.room-bookmarks${_converse.bare_jid}`; cache_key = `converse.room-bookmarks${_converse.bare_jid}`;
this.fetched_flag = cache_key+'fetched'; this.fetched_flag = cache_key+'fetched';
this.browserStorage = new Backbone.BrowserStorage[storage](cache_key); this.browserStorage = new BrowserStorage[storage](cache_key);
}, },
openBookmarkedRoom (bookmark) { openBookmarkedRoom (bookmark) {
...@@ -141,7 +142,7 @@ converse.plugins.add('converse-bookmarks', { ...@@ -141,7 +142,7 @@ converse.plugins.add('converse-bookmarks', {
.c('publish', {'node': 'storage:bookmarks'}) .c('publish', {'node': 'storage:bookmarks'})
.c('item', {'id': 'current'}) .c('item', {'id': 'current'})
.c('storage', {'xmlns':'storage:bookmarks'}); .c('storage', {'xmlns':'storage:bookmarks'});
this.each(model => { this.forEach(model => {
stanza.c('conference', { stanza.c('conference', {
'name': model.get('name'), 'name': model.get('name'),
'autojoin': model.get('autojoin'), 'autojoin': model.get('autojoin'),
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import "./utils/emoji"; import "./utils/emoji";
import "./utils/form"; import "./utils/form";
import BrowserStorage from "backbone.browserStorage";
import converse from "./converse-core"; import converse from "./converse-core";
import filesize from "filesize"; import filesize from "filesize";
...@@ -298,7 +299,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -298,7 +299,7 @@ converse.plugins.add('converse-chatboxes', {
initMessages () { initMessages () {
this.messages = new _converse.Messages(); this.messages = new _converse.Messages();
const storage = _converse.config.get('storage'); const storage = _converse.config.get('storage');
this.messages.browserStorage = new Backbone.BrowserStorage.session( this.messages.browserStorage = new BrowserStorage.session(
`converse.messages-${this.get('jid')}-${_converse.bare_jid}`); `converse.messages-${this.get('jid')}-${_converse.bare_jid}`);
this.messages.chatbox = this; this.messages.chatbox = this;
...@@ -951,7 +952,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -951,7 +952,7 @@ converse.plugins.add('converse-chatboxes', {
}, },
onConnected () { onConnected () {
this.browserStorage = new Backbone.BrowserStorage.session( this.browserStorage = new BrowserStorage.session(
`converse.chatboxes-${_converse.bare_jid}`); `converse.chatboxes-${_converse.bare_jid}`);
this.registerMessageHandler(); this.registerMessageHandler();
this.fetch({ this.fetch({
......
...@@ -384,7 +384,7 @@ function initClientConfig () { ...@@ -384,7 +384,7 @@ function initClientConfig () {
'trusted': _converse.trusted && true || false, 'trusted': _converse.trusted && true || false,
'storage': _converse.trusted ? 'local' : 'session' 'storage': _converse.trusted ? 'local' : 'session'
}); });
_converse.config.browserStorage = new Backbone.BrowserStorage.session(id); _converse.config.browserStorage = new BrowserStorage.session(id);
_converse.config.fetch(); _converse.config.fetch();
/** /**
* Triggered once the XMPP-client configuration has been initialized. * Triggered once the XMPP-client configuration has been initialized.
...@@ -430,7 +430,7 @@ _converse.initConnection = function () { ...@@ -430,7 +430,7 @@ _converse.initConnection = function () {
async function initSession () { async function initSession () {
const id = 'converse.bosh-session'; const id = 'converse.bosh-session';
_converse.session = new Backbone.Model({id}); _converse.session = new Backbone.Model({id});
_converse.session.browserStorage = new Backbone.BrowserStorage.session(id); _converse.session.browserStorage = new BrowserStorage.session(id);
try { try {
await new Promise((success, error) => _converse.session.fetch({success, error})); await new Promise((success, error) => _converse.session.fetch({success, error}));
if (_converse.jid && _converse.session.get('jid') !== _converse.jid) { if (_converse.jid && _converse.session.get('jid') !== _converse.jid) {
...@@ -908,7 +908,7 @@ _converse.initialize = async function (settings, callback) { ...@@ -908,7 +908,7 @@ _converse.initialize = async function (settings, callback) {
} else { } else {
const id = `converse.xmppstatus-${_converse.bare_jid}`; const id = `converse.xmppstatus-${_converse.bare_jid}`;
_converse.xmppstatus = new this.XMPPStatus({'id': id}); _converse.xmppstatus = new this.XMPPStatus({'id': id});
_converse.xmppstatus.browserStorage = new Backbone.BrowserStorage.session(id); _converse.xmppstatus.browserStorage = new BrowserStorage.session(id);
_converse.xmppstatus.fetch({ _converse.xmppstatus.fetch({
'success': _.partial(_converse.onStatusInitialized, reconnecting), 'success': _.partial(_converse.onStatusInitialized, reconnecting),
'error': _.partial(_converse.onStatusInitialized, reconnecting) 'error': _.partial(_converse.onStatusInitialized, reconnecting)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
/* This is a Converse plugin which add support for XEP-0030: Service Discovery */ /* This is a Converse plugin which add support for XEP-0030: Service Discovery */
import BrowserStorage from "backbone.browserStorage";
import converse from "./converse-core"; import converse from "./converse-core";
import sizzle from "sizzle"; import sizzle from "sizzle";
...@@ -40,30 +41,30 @@ converse.plugins.add('converse-disco', { ...@@ -40,30 +41,30 @@ converse.plugins.add('converse-disco', {
this.waitUntilFeaturesDiscovered = utils.getResolveablePromise(); this.waitUntilFeaturesDiscovered = utils.getResolveablePromise();
this.dataforms = new Backbone.Collection(); this.dataforms = new Backbone.Collection();
this.dataforms.browserStorage = new Backbone.BrowserStorage.session( this.dataforms.browserStorage = new BrowserStorage.session(
`converse.dataforms-${this.get('jid')}` `converse.dataforms-${this.get('jid')}`
); );
this.features = new Backbone.Collection(); this.features = new Backbone.Collection();
this.features.browserStorage = new Backbone.BrowserStorage.session( this.features.browserStorage = new BrowserStorage.session(
`converse.features-${this.get('jid')}` `converse.features-${this.get('jid')}`
); );
this.features.on('add', this.onFeatureAdded, this); this.features.on('add', this.onFeatureAdded, this);
this.fields = new Backbone.Collection(); this.fields = new Backbone.Collection();
this.fields.browserStorage = new Backbone.BrowserStorage.session( this.fields.browserStorage = new BrowserStorage.session(
`converse.fields-${this.get('jid')}` `converse.fields-${this.get('jid')}`
); );
this.fields.on('add', this.onFieldAdded, this); this.fields.on('add', this.onFieldAdded, this);
this.identities = new Backbone.Collection(); this.identities = new Backbone.Collection();
this.identities.browserStorage = new Backbone.BrowserStorage.session( this.identities.browserStorage = new BrowserStorage.session(
`converse.identities-${this.get('jid')}` `converse.identities-${this.get('jid')}`
); );
this.fetchFeatures(); this.fetchFeatures();
this.items = new _converse.DiscoEntities(); this.items = new _converse.DiscoEntities();
this.items.browserStorage = new Backbone.BrowserStorage.session( this.items.browserStorage = new BrowserStorage.session(
`converse.disco-items-${this.get('jid')}` `converse.disco-items-${this.get('jid')}`
); );
this.items.fetch(); this.items.fetch();
...@@ -144,7 +145,6 @@ converse.plugins.add('converse-disco', { ...@@ -144,7 +145,6 @@ converse.plugins.add('converse-disco', {
} catch (iq) { } catch (iq) {
_converse.log(iq, Strophe.LogLevel.ERROR); _converse.log(iq, Strophe.LogLevel.ERROR);
this.waitUntilFeaturesDiscovered.resolve(this); this.waitUntilFeaturesDiscovered.resolve(this);
return;
} }
this.onInfo(stanza); this.onInfo(stanza);
}, },
...@@ -179,7 +179,7 @@ converse.plugins.add('converse-disco', { ...@@ -179,7 +179,7 @@ converse.plugins.add('converse-disco', {
}, },
onInfo (stanza) { onInfo (stanza) {
_.forEach(stanza.querySelectorAll('identity'), (identity) => { Array.from(stanza.querySelectorAll('identity')).forEach(identity => {
this.identities.create({ this.identities.create({
'category': identity.getAttribute('category'), 'category': identity.getAttribute('category'),
'type': identity.getAttribute('type'), 'type': identity.getAttribute('type'),
...@@ -261,7 +261,7 @@ converse.plugins.add('converse-disco', { ...@@ -261,7 +261,7 @@ converse.plugins.add('converse-disco', {
function initStreamFeatures () { function initStreamFeatures () {
_converse.stream_features = new Backbone.Collection(); _converse.stream_features = new Backbone.Collection();
_converse.stream_features.browserStorage = new Backbone.BrowserStorage.session( _converse.stream_features.browserStorage = new BrowserStorage.session(
`converse.stream-features-${_converse.bare_jid}` `converse.stream-features-${_converse.bare_jid}`
); );
_converse.stream_features.fetch({ _converse.stream_features.fetch({
...@@ -293,7 +293,7 @@ converse.plugins.add('converse-disco', { ...@@ -293,7 +293,7 @@ converse.plugins.add('converse-disco', {
_converse.connection.addHandler(onDiscoInfoRequest, Strophe.NS.DISCO_INFO, 'iq', 'get', null, null); _converse.connection.addHandler(onDiscoInfoRequest, Strophe.NS.DISCO_INFO, 'iq', 'get', null, null);
_converse.disco_entities = new _converse.DiscoEntities(); _converse.disco_entities = new _converse.DiscoEntities();
_converse.disco_entities.browserStorage = new Backbone.BrowserStorage.session( _converse.disco_entities.browserStorage = new BrowserStorage.session(
`converse.disco-entities-${_converse.bare_jid}` `converse.disco-entities-${_converse.bare_jid}`
); );
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
import "./converse-disco"; import "./converse-disco";
import "./utils/emoji"; import "./utils/emoji";
import "./utils/muc"; import "./utils/muc";
import BrowserStorage from "backbone.browserStorage";
import converse from "./converse-core"; import converse from "./converse-core";
import u from "./utils/form"; import u from "./utils/form";
...@@ -279,13 +280,13 @@ converse.plugins.add('converse-muc', { ...@@ -279,13 +280,13 @@ converse.plugins.add('converse-muc', {
this.features = new Backbone.Model( this.features = new Backbone.Model(
_.assign({id}, _.zipObject(converse.ROOM_FEATURES, _.map(converse.ROOM_FEATURES, _.stubFalse))) _.assign({id}, _.zipObject(converse.ROOM_FEATURES, _.map(converse.ROOM_FEATURES, _.stubFalse)))
); );
this.features.browserStorage = new Backbone.BrowserStorage.session(id); this.features.browserStorage = new BrowserStorage.session(id);
this.features.fetch(); this.features.fetch();
}, },
initOccupants () { initOccupants () {
this.occupants = new _converse.ChatRoomOccupants(); this.occupants = new _converse.ChatRoomOccupants();
this.occupants.browserStorage = new Backbone.BrowserStorage.session( this.occupants.browserStorage = new BrowserStorage.session(
`converse.occupants-${_converse.bare_jid}${this.get('jid')}` `converse.occupants-${_converse.bare_jid}${this.get('jid')}`
); );
this.occupants.chatroom = this; this.occupants.chatroom = this;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
// Copyright (c) 2013-2019, the Converse.js developers // Copyright (c) 2013-2019, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
import BrowserStorage from "backbone.browserStorage";
import converse from "@converse/headless/converse-core"; import converse from "@converse/headless/converse-core";
const { Backbone, Promise, Strophe, $iq, $pres, dayjs, sizzle, _ } = converse.env; const { Backbone, Promise, Strophe, $iq, $pres, dayjs, sizzle, _ } = converse.env;
...@@ -54,17 +55,17 @@ converse.plugins.add('converse-roster', { ...@@ -54,17 +55,17 @@ converse.plugins.add('converse-roster', {
_converse.initRoster = function () { _converse.initRoster = function () {
const storage = _converse.config.get('storage'); const storage = _converse.config.get('storage');
_converse.roster = new _converse.RosterContacts(); _converse.roster = new _converse.RosterContacts();
_converse.roster.browserStorage = new Backbone.BrowserStorage[storage]( _converse.roster.browserStorage = new BrowserStorage[storage](
`converse.contacts-${_converse.bare_jid}`); `converse.contacts-${_converse.bare_jid}`);
_converse.roster.data = new Backbone.Model(); _converse.roster.data = new Backbone.Model();
const id = `converse-roster-model-${_converse.bare_jid}`; const id = `converse-roster-model-${_converse.bare_jid}`;
_converse.roster.data.id = id; _converse.roster.data.id = id;
_converse.roster.data.browserStorage = new Backbone.BrowserStorage[storage](id); _converse.roster.data.browserStorage = new BrowserStorage[storage](id);
_converse.roster.data.fetch(); _converse.roster.data.fetch();
_converse.rostergroups = new _converse.RosterGroups(); _converse.rostergroups = new _converse.RosterGroups();
_converse.rostergroups.browserStorage = new Backbone.BrowserStorage[storage]( _converse.rostergroups.browserStorage = new BrowserStorage[storage](
`converse.roster.groups${_converse.bare_jid}`); `converse.roster.groups${_converse.bare_jid}`);
/** /**
* Triggered once the `_converse.RosterContacts` and `_converse.RosterGroups` have * Triggered once the `_converse.RosterContacts` and `_converse.RosterGroups` have
...@@ -138,7 +139,7 @@ converse.plugins.add('converse-roster', { ...@@ -138,7 +139,7 @@ converse.plugins.add('converse-roster', {
initialize () { initialize () {
this.resources = new Resources(); this.resources = new Resources();
const id = `converse.identities-${this.get('jid')}`; const id = `converse.identities-${this.get('jid')}`;
this.resources.browserStorage = new Backbone.BrowserStorage.session(id); this.resources.browserStorage = new BrowserStorage.session(id);
this.resources.on('update', this.onResourcesChanged, this); this.resources.on('update', this.onResourcesChanged, this);
this.resources.on('change', this.onResourcesChanged, this); this.resources.on('change', this.onResourcesChanged, this);
}, },
...@@ -931,7 +932,7 @@ converse.plugins.add('converse-roster', { ...@@ -931,7 +932,7 @@ converse.plugins.add('converse-roster', {
_converse.presences = new _converse.Presences(); _converse.presences = new _converse.Presences();
} }
_converse.presences.browserStorage = _converse.presences.browserStorage =
new Backbone.BrowserStorage.session(`converse.presences-${_converse.bare_jid}`); new BrowserStorage.session(`converse.presences-${_converse.bare_jid}`);
_converse.presences.fetch(); _converse.presences.fetch();
/** /**
* Triggered once the _converse.Presences collection has been * Triggered once the _converse.Presences collection has been
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// Copyright (c) 2013-2019, the Converse.js developers // Copyright (c) 2013-2019, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
import BrowserStorage from "backbone.browserStorage";
import converse from "./converse-core"; import converse from "./converse-core";
import tpl_vcard from "./templates/vcard.html"; import tpl_vcard from "./templates/vcard.html";
...@@ -122,7 +122,7 @@ converse.plugins.add('converse-vcard', { ...@@ -122,7 +122,7 @@ converse.plugins.add('converse-vcard', {
_converse.initVCardCollection = function () { _converse.initVCardCollection = function () {
_converse.vcards = new _converse.VCards(); _converse.vcards = new _converse.VCards();
const id = `${_converse.bare_jid}-converse.vcards`; const id = `${_converse.bare_jid}-converse.vcards`;
_converse.vcards.browserStorage = new Backbone.BrowserStorage[_converse.config.get('storage')](id); _converse.vcards.browserStorage = new BrowserStorage[_converse.config.get('storage')](id);
_converse.vcards.fetch(); _converse.vcards.fetch();
} }
_converse.api.listen.on('setUserJID', _converse.initVCardCollection); _converse.api.listen.on('setUserJID', _converse.initVCardCollection);
......
...@@ -18,14 +18,6 @@ const config = { ...@@ -18,14 +18,6 @@ const config = {
plugins: [new MiniCssExtractPlugin({filename: '../dist/converse.css'})], plugins: [new MiniCssExtractPlugin({filename: '../dist/converse.css'})],
module: { module: {
rules: [ rules: [
{
test: path.resolve(__dirname, "node_modules/backbone.overview/backbone.orderedlistview"),
use: 'imports-loader?backbone.nativeview'
},
{
test: path.resolve(__dirname, "node_modules/backbone.overview/backbone.overview"),
use: 'imports-loader?backbone.nativeview'
},
{ {
test: path.resolve(__dirname, "node_modules/backbone.vdomview/backbone.vdomview"), test: path.resolve(__dirname, "node_modules/backbone.vdomview/backbone.vdomview"),
use: 'imports-loader?backbone.nativeview' use: 'imports-loader?backbone.nativeview'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment