Commit da1d8764 authored by JC Brand's avatar JC Brand

New config option `clear_messages_on_reconnection`

In some cases, it might be desirable to clear cached chat messages once you've
reconnected to the XMPP server.

For example, if you want to prevent the chat history from getting too long or
if you want to avoid gaps in the chat history (for example due to MAM not
returning all messages since the last cached message).

If you're using OMEMO, then you probably don't want to set this setting to
``true``. OMEMO messages can be decrypted only once, so if they then
subsequently get cleared, you won't get the plaintext back.
parent 67bcc00f
...@@ -18,14 +18,15 @@ ...@@ -18,14 +18,15 @@
- Continuously retry (in 2s intervals) to fetch login credentials (via [credentials_url](https://conversejs.org/docs/html/configuration.html#credentials-url)) in case of failure - Continuously retry (in 2s intervals) to fetch login credentials (via [credentials_url](https://conversejs.org/docs/html/configuration.html#credentials-url)) in case of failure
- Replace `moment` with [DayJS](https://github.com/iamkun/dayjs). - Replace `moment` with [DayJS](https://github.com/iamkun/dayjs).
- New config option [auto_focus](https://conversejs.org/docs/html/configuration.html#auto-focus) - New config option [auto_focus](https://conversejs.org/docs/html/configuration.html#auto-focus)
- New config option [clear_messages_on_reconnection](https://conversejs.org/docs/html/configuration.html#clear-messages-on-reconnection)
- New config option [enable_smacks](https://conversejs.org/docs/html/configuration.html#enable-smacks) - New config option [enable_smacks](https://conversejs.org/docs/html/configuration.html#enable-smacks)
- New config option [muc_show_join_leave_status](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave-status)
- New config option [message_limit](https://conversejs.org/docs/html/configuration.html#message-limit) - New config option [message_limit](https://conversejs.org/docs/html/configuration.html#message-limit)
- New config option [muc_mention_autocomplete_min_chars](https://conversejs.org/docs/html/configuration.html#muc-mention-autocomplete-min-chars)
- New config option [muc_show_join_leave_status](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave-status)
- New config option [singleton](https://conversejs.org/docs/html/configuration.html#singleton) - New config option [singleton](https://conversejs.org/docs/html/configuration.html#singleton)
By setting this option to `false` and `view_mode` to `'embedded'`, it's now possible to By setting this option to `false` and `view_mode` to `'embedded'`, it's now possible to
"embed" the full app and not just a single chat. To embed just a single chat, it's now "embed" the full app and not just a single chat. To embed just a single chat, it's now
necessary to explicitly set `singleton` to `true`. necessary to explicitly set `singleton` to `true`.
- New config option [muc_mention_autocomplete_min_chars](https://conversejs.org/docs/html/configuration.html#muc-mention-autocomplete-min-chars)
- New event: [chatBoxBlurred](https://conversejs.org/docs/html/api/-_converse.html#event:chatBoxBlurred) - New event: [chatBoxBlurred](https://conversejs.org/docs/html/api/-_converse.html#event:chatBoxBlurred)
- New event: [chatReconnected](https://conversejs.org/docs/html/api/-_converse.html#event:chatReconnected) - New event: [chatReconnected](https://conversejs.org/docs/html/api/-_converse.html#event:chatReconnected)
- #316: Add support for XEP-0198 Stream Management - #316: Add support for XEP-0198 Stream Management
......
...@@ -468,6 +468,24 @@ For more information, read this blog post: `Which BOSH server do you need? <http ...@@ -468,6 +468,24 @@ For more information, read this blog post: `Which BOSH server do you need? <http
A more modern alternative to BOSH is to use `websockets <https://developer.mozilla.org/en/docs/WebSockets>`_. A more modern alternative to BOSH is to use `websockets <https://developer.mozilla.org/en/docs/WebSockets>`_.
Please see the :ref:`websocket-url` configuration setting. Please see the :ref:`websocket-url` configuration setting.
clear_messages_on_reconnection
------------------------------
* Default: ``false``
In some cases, it might be desirable to clear cached chat messages once you've
reconnected to the XMPP server.
For example, if you want to prevent the chat history from getting too long or
if you want to avoid gaps in the chat history (for example due to MAM not
returning all messages since the last cached message).
Beware, if you're using OMEMO, then you probably don't want to set this setting to
``true``. OMEMO messages can be decrypted only once, so if they then
subsequently get cleared, you won't get the plaintext back.
chatstate_notification_blacklist chatstate_notification_blacklist
-------------------------------- --------------------------------
......
...@@ -36,6 +36,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -36,6 +36,7 @@ converse.plugins.add('converse-chatboxes', {
// configuration settings. // configuration settings.
_converse.api.settings.update({ _converse.api.settings.update({
'auto_join_private_chats': [], 'auto_join_private_chats': [],
'clear_messages_on_reconnection': false,
'filter_by_resource': false, 'filter_by_resource': false,
'send_chat_state_notifications': true 'send_chat_state_notifications': true
}); });
...@@ -358,7 +359,9 @@ converse.plugins.add('converse-chatboxes', { ...@@ -358,7 +359,9 @@ converse.plugins.add('converse-chatboxes', {
}, },
onReconnection () { onReconnection () {
if (_converse.clear_messages_on_reconnection) {
this.clearMessages(); this.clearMessages();
}
this.announceReconnection(); this.announceReconnection();
}, },
......
...@@ -398,7 +398,9 @@ converse.plugins.add('converse-muc', { ...@@ -398,7 +398,9 @@ converse.plugins.add('converse-muc', {
// the cache (which might be stale). // the cache (which might be stale).
this.removeNonMembers(); this.removeNonMembers();
await this.refreshRoomFeatures(); await this.refreshRoomFeatures();
this.clearMessages(); // XXX: This should be conditional if (_converse.clear_messages_on_reconnection) {
this.clearMessages();
}
if (!u.isPersistableModel(this)) { if (!u.isPersistableModel(this)) {
// XXX: Happens during tests, nothing to do if this // XXX: Happens during tests, nothing to do if this
// is a hanging chatbox (i.e. not in the collection anymore). // is a hanging chatbox (i.e. not in the collection anymore).
......
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