Skip to content

Commit 3b2f7e1

Browse files
committed
(TBR)index: added buttons hook to jingle plugin
EventHookListener: added an event listener to the jingle plugin
1 parent fce9d97 commit 3b2f7e1

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

src/plugins/jingle/index.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,40 @@
44
* @license Mozilla Public License (MPLv2)
55
*/
66

7-
import { converse } from '@converse/headless/core';
7+
import { _converse, converse } from '@converse/headless/core';
8+
import 'plugins/modal/index.js';
9+
import { __ } from 'i18n';
10+
import { html } from "lit";
811

9-
converse.plugins.add('jingle', {
12+
converse.plugins.add('converse-jingle', {
13+
/* Plugin dependencies are other plugins which might be
14+
* overridden or relied upon, and therefore need to be loaded before
15+
* this plugin.
16+
*
17+
* If the setting "strict_plugin_dependencies" is set to true,
18+
* an error will be raised if the plugin is not found. By default it's
19+
* false, which means these plugins are only loaded opportunistically.
20+
*
21+
* NB: These plugins need to have already been loaded via require.js.
22+
*/
23+
dependencies: ['converse-chatview'],
1024

1125
initialize: function () {
12-
26+
/* The initialize function gets called as soon as the plugin is
27+
* loaded by converse.js's plugin machinery.
28+
*/
29+
_converse.api.listen.on('getToolbarButtons', (toolbar_el, buttons) => {
30+
if (!this.is_groupchat) {
31+
const color = '--chat-toolbar-btn-color';
32+
const i18n_start_call = __('Start a call');
33+
buttons.push(html`
34+
<button class="toggle-call" @click=${this.toggleCall} title="${i18n_start_call}">
35+
<converse-icon color="var(${color})" class="fa fa-phone" size="1em"></converse-icon>
36+
</button>`
37+
);
38+
}
39+
40+
return buttons;
41+
});
1342
},
1443
});

src/shared/chat/toolbar.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@ export class ChatToolbar extends CustomElement {
5454
buttons.push(html`<converse-emoji-dropdown .chatview=${chatview}></converse-emoji-dropdown>`);
5555
}
5656

57-
if (!this.is_groupchat) {
58-
const color = '--chat-toolbar-btn-color';
59-
const i18n_start_call = __('Start a call');
60-
buttons.push(html`
61-
<button class="toggle-call" @click=${this.toggleCall} title="${i18n_start_call}">
62-
<converse-icon color="var(${color})" class="fa fa-phone" size="1em"></converse-icon>
63-
</button>`
64-
);
65-
}
66-
6757
const message_limit = api.settings.get('message_limit');
6858
if (message_limit) {
6959
buttons.push(html`

0 commit comments

Comments
 (0)