Adding configurable url history changing

This commit is contained in:
Shaun Wu 2021-04-14 16:56:59 -04:00 committed by JC Brand
parent 4870d41aae
commit 1cb2b1f7a9
6 changed files with 22 additions and 8 deletions

View File

@ -7,6 +7,7 @@
- #2348: `auto_join_room` not showing the room in `fullscreen` `view_mode`. - #2348: `auto_join_room` not showing the room in `fullscreen` `view_mode`.
- #2400: Fixes infinite loop bug when appending .png to allowed image urls - #2400: Fixes infinite loop bug when appending .png to allowed image urls
- #2409: Integrate App Badging API for unread messages - #2409: Integrate App Badging API for unread messages
- #2464: New configuration setting [allow-url-history-change](https://conversejs.org/docs/html/configuration.html#allow-url-history-change)
- Add support for XEP-0437 Room Activity Indicators see [muc-subscribe-to-rai](https://conversejs.org/docs/html/configuration.html#muc-subscribe-to-rai) - Add support for XEP-0437 Room Activity Indicators see [muc-subscribe-to-rai](https://conversejs.org/docs/html/configuration.html#muc-subscribe-to-rai)
- Bugfix: Use real JID in XEP-0372 references only when the MUC is non-anonymous - Bugfix: Use real JID in XEP-0372 references only when the MUC is non-anonymous
- Bugfix: Connection protocol not updated based on XEP-0156 connection methods - Bugfix: Connection protocol not updated based on XEP-0156 connection methods

View File

@ -250,6 +250,12 @@ Support for `XEP-0077: In band registration <https://xmpp.org/extensions/xep-007
Allow XMPP account registration showing the corresponding UI register form interface. Allow XMPP account registration showing the corresponding UI register form interface.
allow_url_history_change
------------------------
* Default: ``true``
Allow Converse to change the browser url bar through the History API <https://developer.mozilla.org/en-US/docs/Web/API/History_API>.
allow_user_trust_override allow_user_trust_override
------------------------- -------------------------

View File

@ -15,6 +15,7 @@ let user_settings; // User settings, populated via api.users.settings
// ---------------------------- // ----------------------------
export const DEFAULT_SETTINGS = { export const DEFAULT_SETTINGS = {
allow_non_roster_messaging: false, allow_non_roster_messaging: false,
allow_url_history_change: true,
assets_path: '/dist', assets_path: '/dist',
authentication: 'login', // Available values are "login", "prebind", "anonymous" and "external". authentication: 'login', // Available values are "login", "prebind", "anonymous" and "external".
auto_login: false, // Currently only used in connection with anonymous login auto_login: false, // Currently only used in connection with anonymous login

View File

@ -1,5 +1,5 @@
import { fetchArchivedMessages } from '@converse/headless/plugins/mam/utils'; import { fetchArchivedMessages } from '@converse/headless/plugins/mam/utils';
import { _converse } from '@converse/headless/core'; import { _converse, api } from '@converse/headless/core';
export async function fetchMessagesOnScrollUp (view) { export async function fetchMessagesOnScrollUp (view) {
if (view.model.messages.length) { if (view.model.messages.length) {
@ -15,7 +15,9 @@ export async function fetchMessagesOnScrollUp (view) {
await fetchArchivedMessages(view.model, { 'end': oldest_message.get('time') }); await fetchArchivedMessages(view.model, { 'end': oldest_message.get('time') });
} }
view.clearSpinner(); view.clearSpinner();
_converse.router.history.navigate(`#${oldest_message.get('msgid')}`); if (api.settings.get('allow_url_history_change')) {
_converse.router.history.navigate(`#${oldest_message.get('msgid')}`);
}
} }
} }
} }

View File

@ -120,9 +120,11 @@ export default class MUCChatArea extends CustomElement {
onScrolledDown () { onScrolledDown () {
if (!this.model.isHidden()) { if (!this.model.isHidden()) {
this.model.clearUnreadMsgCounter(); this.model.clearUnreadMsgCounter();
// Clear location hash if set to one of the messages in our history if (api.settings.get('allow_url_history_change')) {
const hash = window.location.hash; // Clear location hash if set to one of the messages in our history
hash && this.model.messages.get(hash.slice(1)) && _converse.router.history.navigate(); const hash = window.location.hash;
hash && this.model.messages.get(hash.slice(1)) && _converse.router.history.navigate();
}
} }
/** /**
* Triggered once the chat's message area has been scrolled down to the bottom. * Triggered once the chat's message area has been scrolled down to the bottom.

View File

@ -209,9 +209,11 @@ export default class BaseChatView extends ElementView {
this.hideNewMessagesIndicator(); this.hideNewMessagesIndicator();
if (!this.model.isHidden()) { if (!this.model.isHidden()) {
this.model.clearUnreadMsgCounter(); this.model.clearUnreadMsgCounter();
// Clear location hash if set to one of the messages in our history if (api.settings.get('allow_url_history_change')) {
const hash = window.location.hash; // Clear location hash if set to one of the messages in our history
hash && this.model.messages.get(hash.slice(1)) && _converse.router.history.navigate(); const hash = window.location.hash;
hash && this.model.messages.get(hash.slice(1)) && _converse.router.history.navigate();
}
} }
/** /**
* Triggered once the chat's message area has been scrolled down to the bottom. * Triggered once the chat's message area has been scrolled down to the bottom.