|
1 | 1 | import { CustomElement } from 'shared/components/element.js';
|
2 | 2 | import { _converse, api } from "@converse/headless/core";
|
3 |
| -import { JINGLE_CALL_STATUS } from "./constants.js"; |
4 | 3 | import tpl_header_button from "./templates/header-button.js";
|
| 4 | +import { JINGLE_CALL_STATUS } from "./constants.js"; |
5 | 5 |
|
6 |
| -export default class ChatHeaderCallNotification extends CustomElement { |
| 6 | +export default class CallNotification extends CustomElement { |
7 | 7 |
|
| 8 | + static get properties() { |
| 9 | + return { |
| 10 | + 'jid': { type: String }, |
| 11 | + } |
| 12 | + } |
| 13 | + |
8 | 14 | initialize() {
|
9 | 15 | this.model = _converse.chatboxes.get(this.jid);
|
10 |
| - this.listenTo(this.model, 'change:jingle_status', this.requestUpdate); |
| 16 | + this.listenTo(this.model, 'change:jingle_status', () => this.requestUpdate()); |
11 | 17 | }
|
12 | 18 |
|
13 | 19 | render() {
|
14 | 20 | return tpl_header_button(this);
|
15 | 21 | }
|
16 | 22 |
|
17 |
| - toggleJingleCallStatus() { |
| 23 | + endCall() { |
18 | 24 | const jingle_status = this.model.get('jingle_status');
|
19 | 25 | if ( jingle_status === JINGLE_CALL_STATUS.PENDING || jingle_status === JINGLE_CALL_STATUS.ACTIVE) {
|
20 | 26 | this.model.save('jingle_status', JINGLE_CALL_STATUS.ENDED);
|
21 | 27 | return;
|
22 | 28 | }
|
23 |
| - if (!jingle_status || jingle_status === JINGLE_CALL_STATUS.ENDED) { |
24 |
| - this.model.save('jingle_status', JINGLE_CALL_STATUS.PENDING); |
25 |
| - return; |
26 |
| - } |
27 | 29 | }
|
28 | 30 | }
|
29 | 31 |
|
30 |
| -api.elements.define('converse-chat-header-call-notification', ChatHeaderCallNotification); |
| 32 | +api.elements.define('converse-call-notification', CallNotification); |
0 commit comments