@twilio/conversations 2.0.0 → 2.0.1-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +4 -12
- package/dist/browser.js +11 -20
- package/dist/browser.js.map +1 -1
- package/dist/docs/index.html +4 -10
- package/dist/docs/modules.html +4 -10
- package/dist/lib.js +11 -20
- package/dist/lib.js.map +1 -1
- package/dist/react-native.js +13 -17
- package/dist/react-native.js.map +1 -1
- package/dist/twilio-conversations.js +1937 -1097
- package/dist/twilio-conversations.min.js +3 -3
- package/package.json +12 -11
package/dist/react-native.js
CHANGED
@@ -132,9 +132,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
132
132
|
|
133
133
|
var loglevelLog = require('loglevel');
|
134
134
|
var iso8601Duration = require('iso8601-duration');
|
135
|
-
var JsonDiff = require('rfc6902');
|
136
135
|
var declarativeTypeValidator = require('@twilio/declarative-type-validator');
|
137
136
|
var replayEventEmitter = require('@twilio/replay-event-emitter');
|
137
|
+
var isEqual = require('lodash.isequal');
|
138
138
|
var operationRetrier = require('@twilio/operation-retrier');
|
139
139
|
var twilsock = require('twilsock');
|
140
140
|
var notifications = require('@twilio/notifications');
|
@@ -142,6 +142,8 @@ var twilioSync = require('twilio-sync');
|
|
142
142
|
var mcsClient = require('@twilio/mcs-client');
|
143
143
|
var uuid = require('uuid');
|
144
144
|
|
145
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
146
|
+
|
145
147
|
function _interopNamespace(e) {
|
146
148
|
if (e && e.__esModule) return e;
|
147
149
|
var n = Object.create(null);
|
@@ -163,7 +165,7 @@ function _interopNamespace(e) {
|
|
163
165
|
}
|
164
166
|
|
165
167
|
var loglevelLog__namespace = /*#__PURE__*/_interopNamespace(loglevelLog);
|
166
|
-
var
|
168
|
+
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
167
169
|
|
168
170
|
/*! *****************************************************************************
|
169
171
|
Copyright (c) Microsoft Corporation.
|
@@ -283,12 +285,6 @@ class Configuration {
|
|
283
285
|
}
|
284
286
|
}
|
285
287
|
|
286
|
-
/**
|
287
|
-
* Checks if objects are equal
|
288
|
-
*/
|
289
|
-
function isDeepEqual(o1, o2) {
|
290
|
-
return JsonDiff__namespace.createPatch(o1, o2).length === 0;
|
291
|
-
}
|
292
288
|
/**
|
293
289
|
* Deep-clone an object. Note that this does not work on object containing
|
294
290
|
* functions.
|
@@ -455,7 +451,7 @@ class User extends replayEventEmitter.ReplayEventEmitter {
|
|
455
451
|
break;
|
456
452
|
case 'attributes':
|
457
453
|
const updateAttributes = parseAttributes(value.value, `Retrieved malformed attributes from the server for user: ${this.state.identity}`, log$8);
|
458
|
-
if (!
|
454
|
+
if (!isEqual__default['default'](this.state.attributes, updateAttributes)) {
|
459
455
|
this.state.attributes = updateAttributes;
|
460
456
|
updateReasons.push('attributes');
|
461
457
|
}
|
@@ -786,7 +782,7 @@ class Participant extends replayEventEmitter.ReplayEventEmitter {
|
|
786
782
|
_update(data) {
|
787
783
|
let updateReasons = [];
|
788
784
|
let updateAttributes = parseAttributes(data.attributes, 'Retrieved malformed attributes from the server for participant: ' + this.state.sid, log$7);
|
789
|
-
if (data.attributes && !
|
785
|
+
if (data.attributes && !isEqual__default['default'](this.state.attributes, updateAttributes)) {
|
790
786
|
this.state.attributes = updateAttributes;
|
791
787
|
updateReasons.push('attributes');
|
792
788
|
}
|
@@ -1429,7 +1425,7 @@ class Message extends replayEventEmitter.ReplayEventEmitter {
|
|
1429
1425
|
updateReasons.push('dateCreated');
|
1430
1426
|
}
|
1431
1427
|
let updatedAttributes = parseAttributes(data.attributes, `Got malformed attributes for the message ${this.sid}`, log$5);
|
1432
|
-
if (!
|
1428
|
+
if (!isEqual__default['default'](this.state.attributes, updatedAttributes)) {
|
1433
1429
|
this.state.attributes = updatedAttributes;
|
1434
1430
|
updateReasons.push('attributes');
|
1435
1431
|
}
|
@@ -2175,7 +2171,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
2175
2171
|
updateReasons.add(localKey);
|
2176
2172
|
break;
|
2177
2173
|
case fieldMappings.attributes:
|
2178
|
-
if (
|
2174
|
+
if (isEqual__default['default'](this.channelState.attributes, update.attributes)) {
|
2179
2175
|
break;
|
2180
2176
|
}
|
2181
2177
|
this.channelState.attributes = update.attributes;
|
@@ -2206,7 +2202,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
2206
2202
|
this.channelState.lastMessage.dateCreated = update.lastMessage.timestamp;
|
2207
2203
|
updateReasons.add(localKey);
|
2208
2204
|
}
|
2209
|
-
if (
|
2205
|
+
if (isEqual__default['default'](this.channelState.lastMessage, {})) {
|
2210
2206
|
delete this.channelState.lastMessage;
|
2211
2207
|
}
|
2212
2208
|
break;
|
@@ -2215,7 +2211,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
2215
2211
|
if (state !== undefined) {
|
2216
2212
|
state.dateUpdated = new Date(state.dateUpdated);
|
2217
2213
|
}
|
2218
|
-
if (
|
2214
|
+
if (isEqual__default['default'](this.channelState.state, state)) {
|
2219
2215
|
break;
|
2220
2216
|
}
|
2221
2217
|
this.channelState.state = state;
|
@@ -2843,7 +2839,7 @@ class Conversations extends replayEventEmitter.ReplayEventEmitter {
|
|
2843
2839
|
}
|
2844
2840
|
async getConversation(sid) {
|
2845
2841
|
const conversationsMap = await this._getMap();
|
2846
|
-
const page = await conversationsMap.getItems({
|
2842
|
+
const page = await conversationsMap.getItems({ key: sid });
|
2847
2843
|
const items = page.items.map((item) => this._upsertConversation('sync', item.key, item.data));
|
2848
2844
|
return items.length > 0 ? items[0] : null;
|
2849
2845
|
}
|
@@ -2928,7 +2924,7 @@ class Conversations extends replayEventEmitter.ReplayEventEmitter {
|
|
2928
2924
|
if (typeof data.lastConsumedMessageIndex !== 'undefined') {
|
2929
2925
|
updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;
|
2930
2926
|
}
|
2931
|
-
if (!
|
2927
|
+
if (!isEqual__default['default'](updateData, {})) {
|
2932
2928
|
conversation._update(updateData);
|
2933
2929
|
}
|
2934
2930
|
conversation._subscribe().then(() => {
|
@@ -3236,7 +3232,7 @@ class PushNotification {
|
|
3236
3232
|
}
|
3237
3233
|
}
|
3238
3234
|
|
3239
|
-
var version = "2.0.
|
3235
|
+
var version = "2.0.1-rc.4";
|
3240
3236
|
|
3241
3237
|
const trimSlashes = (url) => url.replace(/(^\/+|\/+$)/g, '');
|
3242
3238
|
const isMutationConflictResponse = (response) => response.status.code === 202;
|