Commit 5a4fbe12 authored by Xavi's avatar Xavi Committed by GitHub

Allow getHats method to be overriden (#2308)

parent 03919b97
...@@ -38,6 +38,7 @@ Soon we'll deprecate the latter, so prepare now. ...@@ -38,6 +38,7 @@ Soon we'll deprecate the latter, so prepare now.
- #2285: Rename config option `muc_hats_from_vcard` to [muc_hats](https://conversejs.org/docs/html/configuration.html#muc-hats). Now accepts a list instead of a boolean and allows for more flexible choices regarding user badges. - #2285: Rename config option `muc_hats_from_vcard` to [muc_hats](https://conversejs.org/docs/html/configuration.html#muc-hats). Now accepts a list instead of a boolean and allows for more flexible choices regarding user badges.
- #2304: Custom emojis (stickers) images not shown - #2304: Custom emojis (stickers) images not shown
- #2307: BootstrapModal is not accessible to plugins - #2307: BootstrapModal is not accessible to plugins
- #2308: Allow getHats method to be overriden in the `overrides` object in plugins.
- The `trusted` configuration setting has been removed in favor of two new settings: - The `trusted` configuration setting has been removed in favor of two new settings:
[allow_user_trust_override](https://conversejs.org/docs/html/configuration.html#allow-user-trust-override) [allow_user_trust_override](https://conversejs.org/docs/html/configuration.html#allow-user-trust-override)
[clear_cache_on_logout](https://conversejs.org/docs/html/configuration.html#clear-cache-on-logout) [clear_cache_on_logout](https://conversejs.org/docs/html/configuration.html#clear-cache-on-logout)
......
...@@ -3,7 +3,7 @@ import dayjs from 'dayjs'; ...@@ -3,7 +3,7 @@ import dayjs from 'dayjs';
import tpl_new_day from "../templates//new_day.js"; import tpl_new_day from "../templates//new_day.js";
import { CustomElement } from './element.js'; import { CustomElement } from './element.js';
import { __ } from '../i18n'; import { __ } from '../i18n';
import { api } from "@converse/headless/converse-core"; import { _converse, api } from "@converse/headless/converse-core";
import { html } from 'lit-element'; import { html } from 'lit-element';
import { repeat } from 'lit-html/directives/repeat.js'; import { repeat } from 'lit-html/directives/repeat.js';
...@@ -67,8 +67,10 @@ function getDayIndicator (model) { ...@@ -67,8 +67,10 @@ function getDayIndicator (model) {
}); });
} }
} }
// This is set to _converse so that it can be overriden. An attempt was made to use
function getHats (model) { // a hook instead, but hook returns a promise and it forces the asynchronicity up
// to the render method.
_converse.getHats = function (model) {
if (model.get('type') === 'groupchat') { if (model.get('type') === 'groupchat') {
const allowed_hats = api.settings.get('muc_hats').filter(hat => hat).map((hat) => (hat.toLowerCase())); const allowed_hats = api.settings.get('muc_hats').filter(hat => hat).map((hat) => (hat.toLowerCase()));
let vcard_roles = [] let vcard_roles = []
...@@ -93,7 +95,7 @@ export function getDerivedMessageProps (chatbox, model) { ...@@ -93,7 +95,7 @@ export function getDerivedMessageProps (chatbox, model) {
const is_groupchat = model.get('type') === 'groupchat'; const is_groupchat = model.get('type') === 'groupchat';
return { return {
'has_mentions': is_groupchat && model.get('sender') === 'them' && chatbox.isUserMentioned(model), 'has_mentions': is_groupchat && model.get('sender') === 'them' && chatbox.isUserMentioned(model),
'hats': getHats(model), 'hats': _converse.getHats(model),
'is_first_unread': chatbox.get('first_unread_id') === model.get('id'), 'is_first_unread': chatbox.get('first_unread_id') === model.get('id'),
'is_me_message': model.isMeCommand(), 'is_me_message': model.isMeCommand(),
'is_retracted': model.get('retracted') || model.get('moderated') === 'retracted', 'is_retracted': model.get('retracted') || model.get('moderated') === 'retracted',
......
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