Skip to content

Commit 5c4b40d

Browse files
committed
added the call button at the chat header.
1 parent d31b485 commit 5c4b40d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/plugins/chatview/heading.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default class ChatHeading extends CustomElement {
1717

1818
initialize () {
1919
this.model = _converse.chatboxes.get(this.jid);
20+
this.listenTo(this.model, 'change:jingle_status', this.requestUpdate);
2021
this.listenTo(this.model, 'change:status', this.requestUpdate);
2122
this.listenTo(this.model, 'vcard:add', this.requestUpdate);
2223
this.listenTo(this.model, 'vcard:change', this.requestUpdate);

src/plugins/chatview/templates/chat-head.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { _converse } from '@converse/headless/core';
33
import { getHeadingDropdownItem, getHeadingStandaloneButton } from 'plugins/chatview/utils.js';
44
import { html } from "lit";
55
import { until } from 'lit/directives/until.js';
6+
import { JINGLE_CALL_STATUS } from "../../jingle/constants.js";
67

78

89
async function getStandaloneButtons (promise) {
@@ -42,6 +43,9 @@ export default (o) => {
4243
${ (o.type !== _converse.HEADLINES_TYPE) ? html`<a class="user show-msg-author-modal" @click=${o.showUserDetailsModal}>${ display_name }</a>` : display_name }
4344
</div>
4445
</div>
46+
<div>
47+
${(o.model.get('jingle_status') === JINGLE_CALL_STATUS.PENDING) ? html`<button type="button" class="btn btn-success">Calling...</button>` : ''}
48+
</div>
4549
<div class="chatbox-title__buttons row no-gutters">
4650
${ until(tpl_dropdown_btns(), '') }
4751
${ until(tpl_standalone_btns(), '') }

src/plugins/jingle/index.js

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

7-
import { _converse, converse, api } from '@converse/headless/core';
7+
import { _converse, converse } from '@converse/headless/core';
88
import 'plugins/modal/index.js';
99
import { __ } from 'i18n';
1010
import { html } from "lit";
11-
import AddJingleModal from "./modal/jingle-call-modal.js"
11+
import { startJingleCall } from "./utils.js";
1212

1313

1414
converse.plugins.add('converse-jingle', {
@@ -24,16 +24,16 @@ converse.plugins.add('converse-jingle', {
2424
*/
2525
dependencies: ['converse-chatview'],
2626

27-
initialize: function (o) {
27+
initialize: function () {
2828
/* The initialize function gets called as soon as the plugin is
2929
* loaded by converse.js's plugin machinery.
3030
*/
31-
_converse.api.listen.on('getToolbarButtons', (buttons) => {
31+
_converse.api.listen.on('getToolbarButtons', (toolbar_el, buttons) => {
3232
if (!this.is_groupchat) {
3333
const color = '--chat-toolbar-btn-color';
3434
const i18n_start_call = __('Start a call');
3535
buttons.push(html`
36-
<button class="toggle-call" @click=${(ev) => api.modal.show(AddJingleModal, { 'model': o.model }, ev)} title="${i18n_start_call}">
36+
<button class="toggle-call" @click=${startJingleCall(toolbar_el.model.get('jid'))} title="${i18n_start_call}">
3737
<converse-icon color="var(${color})" class="fa fa-phone" size="1em"></converse-icon>
3838
</button>`
3939
);

0 commit comments

Comments
 (0)