Changes concerning caching of data in the browser.

- Add new configuration setting messages_storage
- Hardcode the storage for roster contacts and chatroom occupants to `sessionStorage`.
This commit is contained in:
JC Brand 2016-08-21 10:49:54 +00:00
parent 95a0b91afa
commit b8aaf751d2
4 changed files with 54 additions and 16 deletions

View File

@ -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

View File

@ -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) <https://xmpp.org/extensions/xep-0313.html>`_
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 <http://www.xmpp.org/extensions/xep-0297.html>`_
message_storage
----------------
* Default: ``session``
Valid options: ``session``, ``local``.
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 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 <https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage>`_
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.
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
-----------------

View File

@ -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

View File

@ -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();