|
@@ -123,30 +123,49 @@ function muteLocalVideo (muted) {
|
123
|
123
|
}
|
124
|
124
|
}
|
125
|
125
|
|
|
126
|
+/**
|
|
127
|
+ * Check if the welcome page is enabled and redirects to it.
|
|
128
|
+ */
|
|
129
|
+function maybeRedirectToWelcomePage() {
|
|
130
|
+ if (!config.enableWelcomePage) {
|
|
131
|
+ return;
|
|
132
|
+ }
|
|
133
|
+ // redirect to welcome page
|
|
134
|
+ setTimeout(() => {
|
|
135
|
+ APP.settings.setWelcomePageEnabled(true);
|
|
136
|
+ window.location.pathname = "/";
|
|
137
|
+ }, 3000);
|
|
138
|
+}
|
|
139
|
+
|
|
140
|
+/**
|
|
141
|
+ * Executes connection.disconnect and shows the feedback dialog
|
|
142
|
+ * @param {boolean} [requestFeedback=false] if user feedback should be requested
|
|
143
|
+ * @returns Promise.
|
|
144
|
+ */
|
|
145
|
+function disconnectAndShowFeedback(requestFeedback) {
|
|
146
|
+ connection.disconnect();
|
|
147
|
+ if (requestFeedback) {
|
|
148
|
+ return APP.UI.requestFeedback();
|
|
149
|
+ } else {
|
|
150
|
+ return Promise.resolve();
|
|
151
|
+ }
|
|
152
|
+}
|
|
153
|
+
|
126
|
154
|
/**
|
127
|
155
|
* Disconnect from the conference and optionally request user feedback.
|
128
|
156
|
* @param {boolean} [requestFeedback=false] if user feedback should be requested
|
129
|
157
|
*/
|
130
|
158
|
function hangup (requestFeedback = false) {
|
131
|
|
- APP.conference._room.leave().then(() => {
|
132
|
|
- connection.disconnect();
|
133
|
|
- if (requestFeedback) {
|
134
|
|
- return APP.UI.requestFeedback();
|
135
|
|
- } else {
|
136
|
|
- return Promise.resolve();
|
137
|
|
- }
|
138
|
|
- }).then(function () {
|
139
|
|
- if (!config.enableWelcomePage) {
|
140
|
|
- return;
|
141
|
|
- }
|
142
|
|
- // redirect to welcome page
|
143
|
|
- setTimeout(() => {
|
144
|
|
- APP.settings.setWelcomePageEnabled(true);
|
145
|
|
- window.location.pathname = "/";
|
146
|
|
- }, 3000);
|
147
|
|
- }, function (err) {
|
148
|
|
- console.error('Failed to hangup the call:', err);
|
149
|
|
- });
|
|
159
|
+ const errCallback = (f, err) => {
|
|
160
|
+ console.error('Error occurred during hanging up: ', err);
|
|
161
|
+ return f();
|
|
162
|
+ };
|
|
163
|
+ const disconnect = disconnectAndShowFeedback.bind(null, requestFeedback);
|
|
164
|
+ APP.conference._room.leave()
|
|
165
|
+ .then(disconnect)
|
|
166
|
+ .catch(errCallback.bind(null, disconnect))
|
|
167
|
+ .then(maybeRedirectToWelcomePage)
|
|
168
|
+ .catch(errCallback.bind(null, maybeRedirectToWelcomePage));
|
150
|
169
|
}
|
151
|
170
|
|
152
|
171
|
/**
|