New config option: `persistent_store`

Allows for using IndexedDB as the persistent store, instead of localStorage
This commit is contained in:
JC Brand 2019-12-03 13:51:57 +01:00
parent 5232019ed7
commit c3447dd205
3 changed files with 37 additions and 17 deletions

View File

@ -8,8 +8,9 @@
- New API [\_converse.api.headlines](https://conversejs.org/docs/html/api/-_converse.api.headlines.html#.get)
- New config option [allow_message_retraction](https://conversejs.org/docs/html/configuration.html#allow-message-retraction)
- New config option [muc-show-logs-before-join](https://conversejs.org/docs/html/configuration.html#muc-show-logs-before-join)
- New config option [muc_mention_autocomplete_filter](https://conversejs.org/docs/html/configuration.html#muc_mention_autocomplete_filter)
- New config option [muc_mention_autocomplete_show_avatar](https://conversejs.org/docs/html/configuration.html#muc_mention_autocomplete_show_avatar)
- New config option [muc_mention_autocomplete_filter](https://conversejs.org/docs/html/configuration.html#muc-mention-autocomplete-filter)
- New config option [muc_mention_autocomplete_show_avatar](https://conversejs.org/docs/html/configuration.html#muc-mention-autocomplete-show_avatar)
- New config option [persistent_store](https://conversejs.org/docs/html/configuration.html#persistent-store)
- Initial support for sending custom emojis. Currently only between Converse
instances. Still working out a wire protocol for compatibility with other clients.

View File

@ -1349,6 +1349,23 @@ compile time.
This configuration seting allows this value to be set at runtime as well.
persistent_store
----------------
* Default: ``localStorage``
* Valid options: ``localStorage``, ``IndexedDB``
Determines which store is used for storing persistent data.
From version 6.0.0 onwards, Converse supports storing data in
`IndexedDB <https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB>`_.
IndexedDB is not subjected to the same space constraints as localStorage and is
also a requirement for progressive web apps which don't need persistent a
internet connectivity to be functional.
push_app_servers
----------------
@ -1514,16 +1531,6 @@ everywhere.
This warning isn't applicable to all deployments of Converse and can therefore
be turned off by setting this config variable to ``false``.
use_system_emojis
-----------------
* Default: ``true``
Determines whether emojis should be rendered by the user's system.
Not all operating systems support (all) emojis. So alternatively you can let
Converse render the emojis with `Twemoji <https://twemoji.twitter.com/>`_.
See also `emoji_image_path`_.
send_chat_state_notifications
-----------------------------
@ -1635,8 +1642,7 @@ synchronize_availability
------------------------
* Default: ``true``
Valid options: ``true``, ``false``, ``a resource name``.
* Valid options: ``true``, ``false``, ``a resource name``.
This option lets you synchronize your chat status (`online`, `busy`, `away`) with other chat clients. In other words,
if you change your status to ``busy`` in a different chat client, your status will change to ``busy`` in Converse as well.
@ -1651,8 +1657,7 @@ theme
-----
* Default: ``default``
Valid options: ``default``, ``concord``
* Valid options: ``default``, ``concord``
Let's you set a color theme for Converse.
@ -1706,6 +1711,18 @@ description of time-format options available for ``DayJS`` you can check the
`default formatting options <https://github.com/iamkun/dayjs/blob/dev/docs/en/API-reference.md#displaying>`_ and the
`advanced options <https://github.com/iamkun/dayjs/blob/master/docs/en/Plugin.md#advancedformat>`_.
use_system_emojis
-----------------
* Default: ``true``
Determines whether emojis should be rendered by the user's system.
Not all operating systems support (all) emojis. So alternatively you can let
Converse render the emojis with `Twemoji <https://twemoji.twitter.com/>`_.
See also `emoji_image_path`_.
visible_toolbar_buttons
-----------------------

View File

@ -268,6 +268,7 @@ _converse.default_settings = {
message_carbons: true,
nickname: undefined,
password: undefined,
persistent_store: 'localStorage',
priority: 0,
rid: undefined,
root: window.document,
@ -448,10 +449,11 @@ function initClientConfig () {
* user sessions.
*/
const id = 'converse.client-config';
const store_map = { 'localStorage': 'local', 'IndexedDB': 'indexed' };
_converse.config = new Backbone.Model({
'id': id,
'trusted': _converse.trusted && true || false,
'storage': _converse.trusted ? 'local' : 'session'
'storage': _converse.trusted ? store_map[_converse.persistent_store] : 'session'
});
_converse.config.browserStorage = _converse.createStore(id, "session");
_converse.config.fetch();