diff --git a/docs/CHANGES.md b/docs/CHANGES.md index ecb815476..fe09656b8 100755 --- a/docs/CHANGES.md +++ b/docs/CHANGES.md @@ -2,6 +2,8 @@ ## 1.0.7 (Unreleased) - Continuously attempt to resurrect dead connections when `auto_reconnect` is `true`. [jcbrand] +- Add new configuration setting [message_storage](https://conversejs.org/docs/html/configuration.html#message_storage) [jcbrand] +- Hardcode the storage for roster contacts and chatroom occupants to `sessionStorage`. [jcbrand] ## 1.0.6 (2016-08-12) - #632 Offline and Logout states do not properly update once users start diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index 8ec031a41..44c84aa68 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -178,7 +178,7 @@ archived_messages_page_size * Default: ``20`` -See also: `message_archiving` +See also: `message_archiving`_ This feature applies to `XEP-0313: Message Archive Management (MAM) `_ and will only take effect if your server supports MAM. @@ -634,6 +634,28 @@ Message carbons is the XEP (Jabber protocol extension) specifically drafted to solve this problem, while `forward_messages`_ uses `stanza forwarding `_ +message_storage +---------------- + +* Default: ``session`` + +Valid options: ``session``, ``local``. + +This option determines the type of `browser storage `_ +(``localStorage`` or ``sessionStorage``) used by converse.js to cache messages (private and group). + +The main difference between the two is that `sessionStorage` only persists while +the current tab or window containing a converse.js instance is open. As soon as +it's closed, the data is cleared. + +Data in `localStorage` on the other hand is kept indefinitely, which can have +privacy implications on public computers or when multiple people are using the +same computer. + +See also the `storage`_ option, which applies to other cached data, such as +which chats you have open, what features the XMPP server supports and what +your online status is. + muc_history_max_stanzas ----------------------- @@ -838,26 +860,39 @@ storage Valid options: ``session``, ``local``. -This option determines the type of `storage `_ +This option determines the type of `browser storage `_ (``localStorage`` or ``sessionStorage``) used by converse.js to cache user data. -Originally converse.js used only localStorage, however sessionStorage is from a +Originally converse.js used only `localStorage`, however `sessionStorage` is from a privacy perspective a better choice. -The main difference between the two is that sessionStorage only persists while +The main difference between the two is that `sessionStorage` only persists while the current tab or window containing a converse.js instance is open. As soon as it's closed, the data is cleared. -Data in localStorage on the other hand is kept indefinitely. +Data in `localStorage` on the other hand is kept indefinitely. + +The data that is cached includes which chats you had open, what features the +XMPP server supports and what your online status was. + +Since version 1.0.7, the store for messages is now configurable separately with +the `message_storage`_ option, to allow you to cache messages for longer in the +browser (with `localStorage`) while still using `sessionStorage` for other +data. .. note:: - Since version 0.8.0, the use of local storage is not recommended. The - statuses (online, away, busy etc.) of your roster contacts are cached in - the browser storage. If you use local storage, these values are stored for - multiple sessions, and they will likely become out of sync with your contacts' - actual statuses. The session storage doesn't have this problem, because - roster contact statuses will not become out of sync in a single session, - only across more than one session. + Between versions 0.8.0 and 1.0.7, setting the value of this option to "local" + is not recommended. The statuses (online, away, busy etc.) of your roster + contacts are cached in the browser storage. If you use local storage, these + values are stored for multiple sessions, and they will likely become out of + sync with your contacts' actual statuses. The session storage doesn't have + this problem, because roster contact statuses will not become out of sync in + a single session, only across more than one session. + + Since version 1.0.7, the "storage" option doesn't apply anymore to how roster + contacts and their statuses are stored (they're now always stored in session + storage), to address the above issue. + sticky_controlbox ----------------- diff --git a/src/converse-core.js b/src/converse-core.js index 94d1b46c3..6c0be897e 100755 --- a/src/converse-core.js +++ b/src/converse-core.js @@ -242,6 +242,7 @@ show_only_online_users: false, sid: undefined, storage: 'session', + message_storage: 'session', strict_plugin_dependencies: false, synchronize_availability: true, // Set to false to not sync with other clients or with resource name of the particular client that it should synchronize with visible_toolbar_buttons: { @@ -640,10 +641,10 @@ this.initRoster = function () { this.roster = new this.RosterContacts(); - this.roster.browserStorage = new Backbone.BrowserStorage[this.storage]( + this.roster.browserStorage = new Backbone.BrowserStorage.session( b64_sha1('converse.contacts-'+this.bare_jid)); this.rostergroups = new converse.RosterGroups(); - this.rostergroups.browserStorage = new Backbone.BrowserStorage[converse.storage]( + this.rostergroups.browserStorage = new Backbone.BrowserStorage.session( b64_sha1('converse.roster.groups'+converse.bare_jid)); }; @@ -1212,7 +1213,7 @@ initialize: function () { this.messages = new converse.Messages(); - this.messages.browserStorage = new Backbone.BrowserStorage[converse.storage]( + this.messages.browserStorage = new Backbone.BrowserStorage[converse.message_storage]( b64_sha1('converse.messages'+this.get('jid')+converse.bare_jid)); this.save({ // The chat_state will be set to ACTIVE once the chat box is opened diff --git a/src/converse-muc.js b/src/converse-muc.js index 6485d57ee..265c18eab 100755 --- a/src/converse-muc.js +++ b/src/converse-muc.js @@ -204,7 +204,7 @@ model: new converse.ChatRoomOccupants({nick: this.model.get('nick')}) }); var id = b64_sha1('converse.occupants'+converse.bare_jid+this.model.get('id')+this.model.get('nick')); - this.occupantsview.model.browserStorage = new Backbone.BrowserStorage[converse.storage](id); + this.occupantsview.model.browserStorage = new Backbone.BrowserStorage.session(id); this.occupantsview.chatroomview = this; this.render().$el.hide();