Call initialize
in CustomElement's connectedCallback
method
This commit is contained in:
parent
7f2ab05f97
commit
48f37aa1c0
@ -3,6 +3,7 @@ const path = require('path');
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
frameworks: ['jasmine'],
|
||||
|
@ -14,11 +14,6 @@ import { _converse, api } from '@converse/headless/core';
|
||||
export default class ChatView extends BaseChatView {
|
||||
length = 200
|
||||
|
||||
connectedCallback () {
|
||||
super.connectedCallback();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
_converse.chatboxviews.add(this.jid, this);
|
||||
this.model = _converse.chatboxes.get(this.jid);
|
||||
|
@ -9,11 +9,6 @@ import './styles/chat-head.scss';
|
||||
|
||||
export default class ChatHeading extends CustomElement {
|
||||
|
||||
connectedCallback () {
|
||||
super.connectedCallback();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
initialize () {
|
||||
this.model = _converse.chatboxes.get(this.getAttribute('jid'));
|
||||
this.listenTo(this.model, 'change:status', this.requestUpdate);
|
||||
|
@ -5,11 +5,6 @@ import { _converse, api } from '@converse/headless/core';
|
||||
|
||||
class HeadlinesView extends BaseChatView {
|
||||
|
||||
connectedCallback () {
|
||||
super.connectedCallback();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
_converse.chatboxviews.add(this.jid, this);
|
||||
|
||||
|
@ -7,11 +7,6 @@ import { initStorage } from '@converse/headless/utils/storage.js';
|
||||
|
||||
export default class MinimizedChats extends CustomElement {
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
async initialize () {
|
||||
this.model = _converse.chatboxes;
|
||||
await this.initToggle();
|
||||
|
@ -17,11 +17,6 @@ export default class MUCChatArea extends CustomElement {
|
||||
}
|
||||
}
|
||||
|
||||
connectedCallback () {
|
||||
super.connectedCallback();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
async initialize () {
|
||||
this.model = await api.rooms.get(this.jid);
|
||||
this.listenTo(this.model, 'change:show_help_messages', () => this.requestUpdate());
|
||||
|
@ -38,11 +38,6 @@ export default class ModeratorTools extends CustomElement {
|
||||
this.roles_filter = '';
|
||||
}
|
||||
|
||||
connectedCallback () {
|
||||
super.connectedCallback();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
updated (changed) {
|
||||
changed.has('role') && this.onSearchRoleChange();
|
||||
changed.has('affiliation') && this.onSearchAffiliationChange();
|
||||
|
@ -7,11 +7,6 @@ export default class MUCView extends BaseChatView {
|
||||
length = 300
|
||||
is_chatroom = true
|
||||
|
||||
connectedCallback () {
|
||||
super.connectedCallback();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
async initialize () {
|
||||
this.model = await api.rooms.get(this.jid);
|
||||
_converse.chatboxviews.add(this.jid, this);
|
||||
|
@ -17,11 +17,6 @@ export const RosterFilter = Model.extend({
|
||||
|
||||
export class RosterFilterView extends CustomElement {
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
initialize () {
|
||||
const model = new _converse.RosterFilter();
|
||||
model.id = `_converse.rosterfilter-${_converse.bare_jid}`;
|
||||
|
@ -11,11 +11,6 @@ import { _converse, api } from "@converse/headless/core";
|
||||
*/
|
||||
export default class RosterView extends CustomElement {
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
async initialize () {
|
||||
await api.waitUntil('rosterInitialized')
|
||||
this.listenTo(_converse, 'rosterContactsFetched', this.requestUpdate);
|
||||
|
@ -15,11 +15,6 @@ export default class ChatContent extends CustomElement {
|
||||
}
|
||||
}
|
||||
|
||||
connectedCallback () {
|
||||
super.connectedCallback();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
disconnectedCallback () {
|
||||
super.disconnectedCallback();
|
||||
this.removeEventListener('scroll', markScrolled);
|
||||
|
@ -2,6 +2,7 @@ import log from '@converse/headless/log';
|
||||
import { CustomElement } from 'shared/components/element.js';
|
||||
import { __ } from 'i18n';
|
||||
import { _converse, api, converse } from '@converse/headless/core.js';
|
||||
import { getAppSettings } from '@converse/headless/shared/settings/utils.js';
|
||||
import { getMediaURLs } from '@converse/headless/shared/chat/utils.js';
|
||||
import { html } from 'lit';
|
||||
import { isMediaURLDomainAllowed } from '@converse/headless/utils/url.js';
|
||||
@ -22,6 +23,15 @@ class MessageActions extends CustomElement {
|
||||
};
|
||||
}
|
||||
|
||||
initialize () {
|
||||
const settings = getAppSettings();
|
||||
this.listenTo(settings, 'change:allowed_audio_domains', () => this.requestUpdate());
|
||||
this.listenTo(settings, 'change:allowed_image_domains', () => this.requestUpdate());
|
||||
this.listenTo(settings, 'change:allowed_video_domains', () => this.requestUpdate());
|
||||
this.listenTo(settings, 'change:render_media', () => this.requestUpdate());
|
||||
}
|
||||
|
||||
|
||||
render () {
|
||||
return html`${until(this.renderActions(), '')}`;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import ImageModal from 'modals/image.js';
|
||||
import renderRichText from 'shared/directives/rich-text.js';
|
||||
import { CustomElement } from 'shared/components/element.js';
|
||||
import { api } from "@converse/headless/core";
|
||||
import { getAppSettings } from '@converse/headless/shared/settings/utils.js';
|
||||
|
||||
import './styles/message-body.scss';
|
||||
|
||||
@ -21,6 +22,14 @@ export default class MessageBody extends CustomElement {
|
||||
}
|
||||
}
|
||||
|
||||
initialize () {
|
||||
const settings = getAppSettings();
|
||||
this.listenTo(settings, 'change:allowed_audio_domains', () => this.requestUpdate());
|
||||
this.listenTo(settings, 'change:allowed_image_domains', () => this.requestUpdate());
|
||||
this.listenTo(settings, 'change:allowed_video_domains', () => this.requestUpdate());
|
||||
this.listenTo(settings, 'change:render_media', () => this.requestUpdate());
|
||||
}
|
||||
|
||||
onImgClick (ev) { // eslint-disable-line class-methods-use-this
|
||||
ev.preventDefault();
|
||||
api.modal.create(ImageModal, {'src': ev.target.src}, ev).show(ev);
|
||||
|
@ -30,11 +30,6 @@ export default class Message extends CustomElement {
|
||||
}
|
||||
}
|
||||
|
||||
connectedCallback () {
|
||||
super.connectedCallback();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
async initialize () {
|
||||
await this.setModels();
|
||||
if (!this.model) {
|
||||
|
@ -14,6 +14,11 @@ export class CustomElement extends LitElement {
|
||||
return this;
|
||||
}
|
||||
|
||||
connectedCallback () {
|
||||
super.connectedCallback();
|
||||
this.initialize?.();
|
||||
}
|
||||
|
||||
disconnectedCallback () {
|
||||
super.disconnectedCallback();
|
||||
this.stopListening();
|
||||
|
@ -6,7 +6,7 @@ import { html } from 'lit';
|
||||
|
||||
import './styles/gif.scss';
|
||||
|
||||
export default class ConverseGIF extends CustomElement {
|
||||
export default class ConverseGIFElement extends CustomElement {
|
||||
static get properties () {
|
||||
/**
|
||||
* @typedef { Object } ConverseGIFComponentProperties
|
||||
@ -33,7 +33,7 @@ export default class ConverseGIF extends CustomElement {
|
||||
this.fallback = 'url';
|
||||
}
|
||||
|
||||
initialize () {
|
||||
initGIF () {
|
||||
const options = {
|
||||
'autoplay': this.autoplay,
|
||||
'loop': !this.noloop,
|
||||
@ -46,7 +46,7 @@ export default class ConverseGIF extends CustomElement {
|
||||
|
||||
updated (changed) {
|
||||
if (!this.supergif || changed.has('src')) {
|
||||
this.initialize();
|
||||
this.initGIF();
|
||||
return;
|
||||
}
|
||||
if (changed.has('autoplay')) {
|
||||
@ -100,4 +100,4 @@ export default class ConverseGIF extends CustomElement {
|
||||
}
|
||||
}
|
||||
|
||||
api.elements.define('converse-gif', ConverseGIF);
|
||||
api.elements.define('converse-gif', ConverseGIFElement);
|
||||
|
Loading…
Reference in New Issue
Block a user