Commit ac366f11 authored by JC Brand's avatar JC Brand

Initial experimental support for IndexedDB

Nothing works currently

updates #1105
parent 291fceeb
......@@ -10,6 +10,7 @@
- #968 Use nickname from VCard when joining a room
- #1091 There's now only one CSS file for all view modes.
- #1094 Show room members who aren't currently online
- #1106 Support for Roster Versioning
- It's now also possible to edit your VCard via the UI
- Automatically grow/shrink input as text is entered/removed
- MP4 and MP3 files when sent as XEP-0066 Out of Band Data, are now playable directly in chat
......
......@@ -1237,7 +1237,7 @@ storage
* Default: ``session``
Valid options: ``session``, ``local``.
Valid options: ``session``, ``local``, ``indexeddb``
This option determines the type of `browser storage <https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage>`_
(``localStorage`` or ``sessionStorage``) used by converse.js to cache user data.
......
......@@ -854,6 +854,14 @@
"underscore": "1.8.3"
}
},
"backbone-indexeddb": {
"version": "github:superfeedr/indexeddb-backbonejs-adapter#446e25040ff0e5e6e9404893cfdb41984dce5d67",
"dev": true,
"requires": {
"backbone": "1.3.3",
"underscore": "1.8.3"
}
},
"backbone.browserStorage": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/backbone.browserStorage/-/backbone.browserStorage-0.0.3.tgz",
......
......@@ -27,6 +27,7 @@ require.config({
"backbone.orderedlistview": "node_modules/backbone.overview/dist/backbone.orderedlistview",
"backbone.overview": "node_modules/backbone.overview/dist/backbone.overview",
"backbone.vdomview": "node_modules/backbone.vdomview/dist/backbone.vdomview",
"backbone.indexeddb": "node_modules/backbone.browserStorage/backbone-indexeddb",
"bootstrap": "node_modules/bootstrap.native/dist/bootstrap-native-v4",
"emojione": "node_modules/emojione/lib/js/emojione",
"es6-promise": "node_modules/es6-promise/dist/es6-promise.auto",
......@@ -144,10 +145,12 @@ require.config({
// define module dependencies for modules not using define
shim: {
'awesomplete': { exports: 'Awesomplete'},
'backbone': { deps: ['lodash'], exports: 'Backbone' },
'backbone.indexeddb': { deps: ['backbone'] },
'backbone.orderedlistview': { deps: ['backbone.nativeview'] },
'backbone.overview': { deps: ['backbone.nativeview'] },
'backbone.vdomview': { deps: ['backbone.nativeview'] },
'awesomplete': { exports: 'Awesomplete'},
'emojione': { exports: 'emojione'},
'xss': {
'init': function (xss_noconflict) {
......
......@@ -264,9 +264,10 @@
_converse.api.waitUntil('rosterContactsFetched').then(() => {
this.addRelatedContact(_converse.roster.findWhere({'jid': this.get('jid')}));
});
const store_name = b64_sha1(`converse.messages${this.get('jid')}${_converse.bare_jid}`);
this.messages = new _converse.Messages();
this.messages.browserStorage = new Backbone.BrowserStorage[_converse.storage](
b64_sha1(`converse.messages${this.get('jid')}${_converse.bare_jid}`));
this.messages.browserStorage = new Backbone.BrowserStorage['indexeddb'](store_name, _converse.database);
this.messages.chatbox = this;
this.messages.on('change:upload', (message) => {
......
......@@ -238,6 +238,18 @@
_converse.router = new Backbone.Router();
_converse.database = {
'id': "converse-database",
'description': "The IndexedDB database for the Converse",
'migrations' : [{
'version': '1.0',
'migrate': function (transaction, next) {
var store = transaction.db.createObjectStore("");
}
}]
}
_converse.initialize = function (settings, callback) {
"use strict";
......@@ -335,7 +347,7 @@
show_only_online_users: false,
show_send_button: false,
sid: undefined,
storage: 'session',
storage: 'session', // Can be 'session', 'local' or 'indexeddb'
strict_plugin_dependencies: false,
synchronize_availability: true,
trusted: true,
......
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