|
@@ -27,12 +27,16 @@ class RingOverlay {
|
27
|
27
|
constructor(callee) {
|
28
|
28
|
this._containerId = 'ringOverlay';
|
29
|
29
|
this._audioContainerId = 'ringOverlayRinging';
|
30
|
|
-
|
|
30
|
+ this.isRinging = true;
|
31
|
31
|
this.callee = callee;
|
32
|
32
|
this.render();
|
33
|
33
|
this.audio = document.getElementById(this._audioContainerId);
|
34
|
34
|
this.audio.play();
|
35
|
35
|
this._setAudioTimeout();
|
|
36
|
+ this._timeout = setTimeout(() => {
|
|
37
|
+ this.destroy();
|
|
38
|
+ this.render();
|
|
39
|
+ }, 30000);
|
36
|
40
|
}
|
37
|
41
|
|
38
|
42
|
/**
|
|
@@ -54,13 +58,15 @@ class RingOverlay {
|
54
|
58
|
* Builds and appends the ring overlay to the html document
|
55
|
59
|
*/
|
56
|
60
|
_getHtmlStr(callee) {
|
|
61
|
+ let callingLabel = this.isRinging? "<p>Calling...</p>" : "";
|
|
62
|
+ let callerStateLabel = this.isRinging? "" : " isn't available";
|
57
|
63
|
return `
|
58
|
64
|
<div id="${this._containerId}" class='ringing' >
|
59
|
65
|
<div class='ringing__content'>
|
60
|
|
- <p>Calling...</p>
|
|
66
|
+ ${callingLabel}
|
61
|
67
|
<img class='ringing__avatar' src="${callee.getAvatarUrl()}" />
|
62
|
68
|
<div class="ringing__caller-info">
|
63
|
|
- <p>${callee.getName()}</p>
|
|
69
|
+ <p>${callee.getName()}${callerStateLabel}</p>
|
64
|
70
|
</div>
|
65
|
71
|
</div>
|
66
|
72
|
<audio id="${this._audioContainerId}" src="/sounds/ring.ogg" />
|
|
@@ -80,10 +86,7 @@ class RingOverlay {
|
80
|
86
|
* related to the ring overlay.
|
81
|
87
|
*/
|
82
|
88
|
destroy() {
|
83
|
|
- if (this.interval) {
|
84
|
|
- clearInterval(this.interval);
|
85
|
|
- }
|
86
|
|
-
|
|
89
|
+ this._stopAudio();
|
87
|
90
|
this._detach();
|
88
|
91
|
}
|
89
|
92
|
|
|
@@ -95,6 +98,16 @@ class RingOverlay {
|
95
|
98
|
$(`#${this._containerId}`).remove();
|
96
|
99
|
}
|
97
|
100
|
|
|
101
|
+ _stopAudio() {
|
|
102
|
+ this.isRinging = false;
|
|
103
|
+ if (this.interval) {
|
|
104
|
+ clearInterval(this.interval);
|
|
105
|
+ }
|
|
106
|
+ if(this._timeout) {
|
|
107
|
+ clearTimeout(this._timeout);
|
|
108
|
+ }
|
|
109
|
+ }
|
|
110
|
+
|
98
|
111
|
/**
|
99
|
112
|
* Sets the interval that is going to play the ringing sound.
|
100
|
113
|
*/
|