@@ -7,27 +7,25 @@ import { onScrolledDown } from './utils.js';
7
7
8
8
const { CHATROOMS_TYPE , INACTIVE } = constants ;
9
9
10
-
11
10
export default class BaseChatView extends CustomElement {
12
-
13
- static get properties ( ) {
11
+ static get properties ( ) {
14
12
return {
15
- jid : { type : String }
16
- }
13
+ jid : { type : String } ,
14
+ } ;
17
15
}
18
16
19
- constructor ( ) {
17
+ constructor ( ) {
20
18
super ( ) ;
21
19
this . jid = /** @type {string } */ null ;
22
20
this . model = /** @type {Model } */ null ;
23
21
}
24
22
25
- disconnectedCallback ( ) {
23
+ disconnectedCallback ( ) {
26
24
super . disconnectedCallback ( ) ;
27
25
_converse . state . chatboxviews . remove ( this . jid , this ) ;
28
26
}
29
27
30
- updated ( ) {
28
+ updated ( ) {
31
29
if ( this . model && this . jid !== this . model . get ( 'jid' ) ) {
32
30
this . stopListening ( ) ;
33
31
_converse . state . chatboxviews . remove ( this . model . get ( 'jid' ) , this ) ;
@@ -37,32 +35,35 @@ export default class BaseChatView extends CustomElement {
37
35
}
38
36
}
39
37
40
- close ( ev ) {
38
+ /**
39
+ * @param {MouseEvent } ev
40
+ */
41
+ close ( ev ) {
41
42
ev ?. preventDefault ?. ( ) ;
42
- return this . model . close ( ev ) ;
43
+ return this . model ? .close ( ev ) ;
43
44
}
44
45
45
- maybeFocus ( ) {
46
+ maybeFocus ( ) {
46
47
api . settings . get ( 'auto_focus' ) && this . focus ( ) ;
47
48
}
48
49
49
- focus ( ) {
50
+ focus ( ) {
50
51
const textarea_el = this . getElementsByClassName ( 'chat-textarea' ) [ 0 ] ;
51
52
if ( textarea_el && document . activeElement !== textarea_el ) {
52
- /** @type {HTMLTextAreaElement } */ ( textarea_el ) . focus ( ) ;
53
+ /** @type {HTMLTextAreaElement } */ ( textarea_el ) . focus ( ) ;
53
54
}
54
55
return this ;
55
56
}
56
57
57
- getBottomPanel ( ) {
58
+ getBottomPanel ( ) {
58
59
if ( this . model . get ( 'type' ) === CHATROOMS_TYPE ) {
59
60
return this . querySelector ( 'converse-muc-bottom-panel' ) ;
60
61
} else {
61
62
return this . querySelector ( 'converse-chat-bottom-panel' ) ;
62
63
}
63
64
}
64
65
65
- getMessageForm ( ) {
66
+ getMessageForm ( ) {
66
67
if ( this . model . get ( 'type' ) === CHATROOMS_TYPE ) {
67
68
return this . querySelector ( 'converse-muc-message-form' ) ;
68
69
} else {
@@ -77,7 +78,7 @@ export default class BaseChatView extends CustomElement {
77
78
* whether the user scrolled up manually or not.
78
79
* @param { Event } [ev] - An optional event that is the cause for needing to scroll down.
79
80
*/
80
- scrollDown ( ev ) {
81
+ scrollDown ( ev ) {
81
82
ev ?. preventDefault ?. ( ) ;
82
83
ev ?. stopPropagation ?. ( ) ;
83
84
if ( this . model . ui . get ( 'scrolled' ) ) {
@@ -86,7 +87,7 @@ export default class BaseChatView extends CustomElement {
86
87
onScrolledDown ( this . model ) ;
87
88
}
88
89
89
- onWindowStateChanged ( ) {
90
+ onWindowStateChanged ( ) {
90
91
if ( document . hidden ) {
91
92
this . model . setChatState ( INACTIVE , { 'silent' : true } ) ;
92
93
} else {
0 commit comments