|
@@ -25,29 +25,39 @@ MiddlewareRegistry.register(store => next => action => {
|
25
|
25
|
const result = next(action);
|
26
|
26
|
|
27
|
27
|
switch (action.type) {
|
28
|
|
- case CONFERENCE_FAILED:
|
|
28
|
+ case CONFERENCE_FAILED: {
|
|
29
|
+ const { error, ...data } = action;
|
|
30
|
+
|
|
31
|
+ // XXX Certain CONFERENCE_FAILED errors are recoverable i.e. they have
|
|
32
|
+ // prevented the user from joining a specific conference but the app may
|
|
33
|
+ // be able to eventually join the conference. For example, the app will
|
|
34
|
+ // ask the user for a password upon
|
|
35
|
+ // JitsiConferenceErrors.PASSWORD_REQUIRED and will retry joining the
|
|
36
|
+ // conference afterwards. Such errors are to not reach the native
|
|
37
|
+ // counterpart of the External API (or at least not in the
|
|
38
|
+ // fatality/finality semantics attributed to
|
|
39
|
+ // conferenceFailed:/onConferenceFailed).
|
|
40
|
+ if (!error.recoverable) {
|
|
41
|
+ _sendConferenceEvent(store, /* action */ {
|
|
42
|
+ error: _toErrorString(error),
|
|
43
|
+ ...data
|
|
44
|
+ });
|
|
45
|
+ }
|
|
46
|
+ break;
|
|
47
|
+ }
|
|
48
|
+
|
29
|
49
|
case CONFERENCE_JOINED:
|
30
|
50
|
case CONFERENCE_LEFT:
|
31
|
51
|
case CONFERENCE_WILL_JOIN:
|
32
|
|
- case CONFERENCE_WILL_LEAVE: {
|
33
|
|
- const { conference, type, ...data } = action;
|
34
|
|
-
|
35
|
|
- // For the above (redux) actions, conference identifies a
|
36
|
|
- // JitsiConference instance. The external API cannot transport such an
|
37
|
|
- // object so we have to transport an "equivalent".
|
38
|
|
- if (conference) {
|
39
|
|
- data.url = toURLString(conference[JITSI_CONFERENCE_URL_KEY]);
|
40
|
|
- }
|
41
|
|
-
|
42
|
|
- _sendEvent(store, _getSymbolDescription(type), data);
|
|
52
|
+ case CONFERENCE_WILL_LEAVE:
|
|
53
|
+ _sendConferenceEvent(store, action);
|
43
|
54
|
break;
|
44
|
|
- }
|
45
|
55
|
|
46
|
56
|
case LOAD_CONFIG_ERROR: {
|
47
|
57
|
const { error, locationURL, type } = action;
|
48
|
58
|
|
49
|
|
- _sendEvent(store, _getSymbolDescription(type), {
|
50
|
|
- error: String(error),
|
|
59
|
+ _sendEvent(store, _getSymbolDescription(type), /* data */ {
|
|
60
|
+ error: _toErrorString(error),
|
51
|
61
|
url: toURLString(locationURL)
|
52
|
62
|
});
|
53
|
63
|
break;
|
|
@@ -57,6 +67,26 @@ MiddlewareRegistry.register(store => next => action => {
|
57
|
67
|
return result;
|
58
|
68
|
});
|
59
|
69
|
|
|
70
|
+/**
|
|
71
|
+ * Returns a {@code String} representation of a specific error {@code Object}.
|
|
72
|
+ *
|
|
73
|
+ * @param {Error|Object|string} error - The error {@code Object} to return a
|
|
74
|
+ * {@code String} representation of.
|
|
75
|
+ * @returns {string} A {@code String} representation of the specified
|
|
76
|
+ * {@code error}.
|
|
77
|
+ */
|
|
78
|
+function _toErrorString(
|
|
79
|
+ error: Error | { message: ?string, name: ?string } | string) {
|
|
80
|
+ // XXX In lib-jitsi-meet and jitsi-meet we utilize errors in the form of
|
|
81
|
+ // strings, Error instances, and plain objects which resemble Error.
|
|
82
|
+ return (
|
|
83
|
+ error
|
|
84
|
+ ? typeof error === 'string'
|
|
85
|
+ ? error
|
|
86
|
+ : Error.prototype.toString(error)
|
|
87
|
+ : '');
|
|
88
|
+}
|
|
89
|
+
|
60
|
90
|
/**
|
61
|
91
|
* Gets the description of a specific {@code Symbol}.
|
62
|
92
|
*
|
|
@@ -80,6 +110,27 @@ function _getSymbolDescription(symbol: Symbol) {
|
80
|
110
|
return description;
|
81
|
111
|
}
|
82
|
112
|
|
|
113
|
+/**
|
|
114
|
+ * Sends an event to the native counterpart of the External API for a specific
|
|
115
|
+ * conference-related redux action.
|
|
116
|
+ *
|
|
117
|
+ * @param {Store} store - The redux store.
|
|
118
|
+ * @param {Action} action - The redux action.
|
|
119
|
+ * @returns {void}
|
|
120
|
+ */
|
|
121
|
+function _sendConferenceEvent(
|
|
122
|
+ store: Object,
|
|
123
|
+ { conference, type, ...data }: { conference: Object, type: Symbol }) {
|
|
124
|
+ // For these (redux) actions, conference identifies a JitsiConference
|
|
125
|
+ // instance. The external API cannot transport such an object so we have to
|
|
126
|
+ // transport an "equivalent".
|
|
127
|
+ if (conference) {
|
|
128
|
+ data.url = toURLString(conference[JITSI_CONFERENCE_URL_KEY]);
|
|
129
|
+ }
|
|
130
|
+
|
|
131
|
+ _sendEvent(store, _getSymbolDescription(type), data);
|
|
132
|
+}
|
|
133
|
+
|
83
|
134
|
/**
|
84
|
135
|
* Sends a specific event to the native counterpart of the External API. Native
|
85
|
136
|
* apps may listen to such events via the mechanisms provided by the (native)
|