@amityco/ts-sdk 7.7.1-99f7166.0 → 7.7.1-b56aa2f.0
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/dist/@types/core/events.d.ts +1 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +1 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelSetUserMuted.d.ts.map +1 -1
- package/dist/channelRepository/internalApi/getMyMembership.d.ts +11 -0
- package/dist/channelRepository/internalApi/getMyMembership.d.ts.map +1 -0
- package/dist/channelRepository/observers/getMyMembership.d.ts +2 -0
- package/dist/channelRepository/observers/getMyMembership.d.ts.map +1 -0
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/index.cjs.js +2642 -2548
- package/dist/index.esm.js +622 -528
- package/dist/index.umd.js +3 -3
- package/dist/liveStreamPlayer/utils/eventRegister.d.ts +2 -1
- package/dist/liveStreamPlayer/utils/eventRegister.d.ts.map +1 -1
- package/dist/streamRepository/events/index.d.ts +2 -0
- package/dist/streamRepository/events/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +1 -1
- package/src/@types/core/payload.ts +1 -1
- package/src/@types/domains/channel.ts +3 -0
- package/src/channelRepository/api/createChannel.ts +1 -1
- package/src/channelRepository/events/onChannelSetUserMuted.ts +11 -13
- package/src/channelRepository/internalApi/getMyMembership.ts +37 -0
- package/src/channelRepository/observers/getMyMembership.ts +98 -0
- package/src/core/events.ts +3 -1
- package/src/liveStreamPlayer/api/getPlayer.ts +1 -1
- package/src/liveStreamPlayer/utils/eventRegister.ts +16 -1
- package/src/streamRepository/events/index.ts +2 -0
- package/src/utils/linkedObject/channelLinkedObject.ts +3 -0
- package/src/utils/linkedObject/postLinkedObject.ts +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1367,7 +1367,8 @@ const MQTT_EVENTS = [
|
|
|
1367
1367
|
'video-streaming.didStop',
|
|
1368
1368
|
'video-streaming.didFlag',
|
|
1369
1369
|
'video-streaming.didTerminate',
|
|
1370
|
-
|
|
1370
|
+
'video-streaming.viewerDidBan',
|
|
1371
|
+
'video-streaming.viewerDidUnban',
|
|
1371
1372
|
'liveReaction.created',
|
|
1372
1373
|
];
|
|
1373
1374
|
/** @hidden */
|
|
@@ -22161,6 +22162,577 @@ const channelMemberLinkedObject = (channelMember) => {
|
|
|
22161
22162
|
} });
|
|
22162
22163
|
};
|
|
22163
22164
|
|
|
22165
|
+
/**
|
|
22166
|
+
*
|
|
22167
|
+
* get current user's membership data
|
|
22168
|
+
*
|
|
22169
|
+
* @returns the {@link Amity.Membership<'channel'>} objects
|
|
22170
|
+
*
|
|
22171
|
+
* @category Channel API
|
|
22172
|
+
* @async
|
|
22173
|
+
*/
|
|
22174
|
+
const getMyMembership$1 = (channelId) => {
|
|
22175
|
+
const client = getActiveClient();
|
|
22176
|
+
client.log('channel/getMyMembership.locally');
|
|
22177
|
+
const cacheChannelUser = pullFromCache([
|
|
22178
|
+
'channelUsers',
|
|
22179
|
+
'get',
|
|
22180
|
+
`${channelId}#${client.userId}`,
|
|
22181
|
+
]);
|
|
22182
|
+
if (!cacheChannelUser) {
|
|
22183
|
+
throw new ASCApiError('Item not found!', 400400 /* Amity.ServerError.ITEM_NOT_FOUND */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
22184
|
+
}
|
|
22185
|
+
return {
|
|
22186
|
+
data: cacheChannelUser.data,
|
|
22187
|
+
cachedAt: cacheChannelUser.cachedAt,
|
|
22188
|
+
};
|
|
22189
|
+
};
|
|
22190
|
+
|
|
22191
|
+
/**
|
|
22192
|
+
* ```js
|
|
22193
|
+
* import { isEqual } from '~/utils/isEqual'
|
|
22194
|
+
* const isEqual = isEqual(post1, post2)
|
|
22195
|
+
* ```
|
|
22196
|
+
*
|
|
22197
|
+
* Compares two Amity.Model
|
|
22198
|
+
*
|
|
22199
|
+
* @param x the Amity.Model to compare
|
|
22200
|
+
* @param y the Amity.Model to compare wit x
|
|
22201
|
+
* @returns a boolean based on equality
|
|
22202
|
+
*
|
|
22203
|
+
* @category utility
|
|
22204
|
+
* @private
|
|
22205
|
+
*/
|
|
22206
|
+
function isEqual(x, y) {
|
|
22207
|
+
if (x === null || x === undefined || y === null || y === undefined) {
|
|
22208
|
+
return x === y;
|
|
22209
|
+
}
|
|
22210
|
+
// after this just checking type of one would be enough
|
|
22211
|
+
if (x.constructor !== y.constructor) {
|
|
22212
|
+
return false;
|
|
22213
|
+
}
|
|
22214
|
+
// if they are functions, they should exactly refer to same one (because of closures)
|
|
22215
|
+
if (x instanceof Function) {
|
|
22216
|
+
return x === y;
|
|
22217
|
+
}
|
|
22218
|
+
// if they are regexps, they should exactly refer to same one
|
|
22219
|
+
if (x instanceof RegExp) {
|
|
22220
|
+
return x === y;
|
|
22221
|
+
}
|
|
22222
|
+
if (x === y || x.valueOf() === y.valueOf()) {
|
|
22223
|
+
return true;
|
|
22224
|
+
}
|
|
22225
|
+
if (Array.isArray(x) && x.length !== y.length) {
|
|
22226
|
+
return false;
|
|
22227
|
+
}
|
|
22228
|
+
// check each element of the array for equality
|
|
22229
|
+
if (Array.isArray(x) && Array.isArray(y)) {
|
|
22230
|
+
if (x.length !== y.length)
|
|
22231
|
+
return false;
|
|
22232
|
+
for (let i = 0; i < x.length; i += 1) {
|
|
22233
|
+
if (!isEqual(x[i], y[i]))
|
|
22234
|
+
return false;
|
|
22235
|
+
}
|
|
22236
|
+
// if all elements are equal, the arrays are equal
|
|
22237
|
+
return true;
|
|
22238
|
+
}
|
|
22239
|
+
// if they are dates, they must had equal valueOf
|
|
22240
|
+
if (x instanceof Date) {
|
|
22241
|
+
return false;
|
|
22242
|
+
}
|
|
22243
|
+
// if they are strictly equal, they both need to be object at least
|
|
22244
|
+
if (!(x instanceof Object)) {
|
|
22245
|
+
return false;
|
|
22246
|
+
}
|
|
22247
|
+
if (!(y instanceof Object)) {
|
|
22248
|
+
return false;
|
|
22249
|
+
}
|
|
22250
|
+
// recursive object equality check
|
|
22251
|
+
const p = Object.keys(x);
|
|
22252
|
+
return (Object.keys(y).every(i => {
|
|
22253
|
+
// @ts-ignore
|
|
22254
|
+
return p.indexOf(i) !== -1;
|
|
22255
|
+
}) &&
|
|
22256
|
+
p.every(i => {
|
|
22257
|
+
return isEqual(x[i], y[i]);
|
|
22258
|
+
}));
|
|
22259
|
+
}
|
|
22260
|
+
|
|
22261
|
+
const callbacks$c = [];
|
|
22262
|
+
let mainDisposer$b = null;
|
|
22263
|
+
const dispose$c = (cb) => {
|
|
22264
|
+
const index = callbacks$c.indexOf(cb);
|
|
22265
|
+
if (index > -1) {
|
|
22266
|
+
callbacks$c.splice(index, 1);
|
|
22267
|
+
}
|
|
22268
|
+
if (callbacks$c.length === 0) {
|
|
22269
|
+
mainDisposer$b === null || mainDisposer$b === void 0 ? void 0 : mainDisposer$b();
|
|
22270
|
+
}
|
|
22271
|
+
};
|
|
22272
|
+
const onChannelCreated = (callback) => {
|
|
22273
|
+
if (callbacks$c.length === 0) {
|
|
22274
|
+
const client = getActiveClient();
|
|
22275
|
+
const filter = async (payload) => {
|
|
22276
|
+
const data = await prepareChannelPayload(payload);
|
|
22277
|
+
ingestInCache(data);
|
|
22278
|
+
callbacks$c.forEach(cb => cb(data.channels[0]));
|
|
22279
|
+
};
|
|
22280
|
+
mainDisposer$b = createEventSubscriber(client, 'onChannelCreated', 'channel.created', filter);
|
|
22281
|
+
}
|
|
22282
|
+
callbacks$c.push(callback);
|
|
22283
|
+
return () => dispose$c(callback);
|
|
22284
|
+
};
|
|
22285
|
+
|
|
22286
|
+
const callbacks$b = [];
|
|
22287
|
+
const mainDisposers = [];
|
|
22288
|
+
const dispose$b = (cb) => {
|
|
22289
|
+
const index = callbacks$b.indexOf(cb);
|
|
22290
|
+
if (index > -1) {
|
|
22291
|
+
callbacks$b.splice(index, 1);
|
|
22292
|
+
}
|
|
22293
|
+
if (callbacks$b.length === 0) {
|
|
22294
|
+
mainDisposers.forEach(fn => fn());
|
|
22295
|
+
}
|
|
22296
|
+
};
|
|
22297
|
+
const onChannelUpdated = (callback) => {
|
|
22298
|
+
const client = getActiveClient();
|
|
22299
|
+
if (callbacks$b.length === 0) {
|
|
22300
|
+
const filter = async (payload) => {
|
|
22301
|
+
const data = await prepareChannelPayload(payload);
|
|
22302
|
+
ingestInCache(data);
|
|
22303
|
+
callbacks$b.forEach(cb => cb(data.channels[0]));
|
|
22304
|
+
};
|
|
22305
|
+
mainDisposers.push(createEventSubscriber(client, 'onChannelUpdated', 'channel.updated', filter));
|
|
22306
|
+
mainDisposers.push(createEventSubscriber(client, 'onChannelUpdated', 'local.channel.updated', payload => callbacks$b.forEach(cb => cb(payload.channels[0]))));
|
|
22307
|
+
}
|
|
22308
|
+
callbacks$b.push(callback);
|
|
22309
|
+
return () => dispose$b(callback);
|
|
22310
|
+
};
|
|
22311
|
+
|
|
22312
|
+
const addFlagIsDeletedSubChannelUnreadByChannelId = (channelId) => {
|
|
22313
|
+
const cacheKey = ['subChannelUnreadInfo', 'get'];
|
|
22314
|
+
const cachedSubChannelUnread = queryCache(cacheKey);
|
|
22315
|
+
if (cachedSubChannelUnread) {
|
|
22316
|
+
const cachedTargetSubChannelUnread = cachedSubChannelUnread === null || cachedSubChannelUnread === void 0 ? void 0 : cachedSubChannelUnread.filter(({ data }) => data.channelId === channelId);
|
|
22317
|
+
cachedTargetSubChannelUnread.forEach(({ key, data }) => {
|
|
22318
|
+
pushToCache(key, Object.assign(Object.assign({}, data), { isDeleted: true }));
|
|
22319
|
+
});
|
|
22320
|
+
}
|
|
22321
|
+
};
|
|
22322
|
+
|
|
22323
|
+
const deleteChannelUnreadByChannelId = (channelId) => {
|
|
22324
|
+
var _a;
|
|
22325
|
+
const channelUnreadInfoCacheKey = ['channelUnreadInfo', 'get', channelId];
|
|
22326
|
+
const channelUnreadInfoCache = (_a = pullFromCache(channelUnreadInfoCacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22327
|
+
if (channelUnreadInfoCache) {
|
|
22328
|
+
dropFromCache(channelUnreadInfoCacheKey);
|
|
22329
|
+
}
|
|
22330
|
+
};
|
|
22331
|
+
|
|
22332
|
+
const callbacks$a = [];
|
|
22333
|
+
let mainDisposer$a = null;
|
|
22334
|
+
const dispose$a = (cb) => {
|
|
22335
|
+
const index = callbacks$a.indexOf(cb);
|
|
22336
|
+
if (index > -1) {
|
|
22337
|
+
callbacks$a.splice(index, 1);
|
|
22338
|
+
}
|
|
22339
|
+
if (callbacks$a.length === 0) {
|
|
22340
|
+
mainDisposer$a === null || mainDisposer$a === void 0 ? void 0 : mainDisposer$a();
|
|
22341
|
+
}
|
|
22342
|
+
};
|
|
22343
|
+
const onChannelDeleted = (callback) => {
|
|
22344
|
+
if (callbacks$a.length === 0) {
|
|
22345
|
+
const client = getActiveClient();
|
|
22346
|
+
const filter = async (payload) => {
|
|
22347
|
+
const data = await prepareChannelPayload(payload);
|
|
22348
|
+
const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
|
|
22349
|
+
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
22350
|
+
data.channels.forEach(channel => {
|
|
22351
|
+
if (isConsistentMode) {
|
|
22352
|
+
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
22353
|
+
deleteChannelUnreadByChannelId(channel.channelId);
|
|
22354
|
+
}
|
|
22355
|
+
else if (isLegacyUnreadCount) {
|
|
22356
|
+
const cacheKey = ['channelUnread', 'get', channel.channelId];
|
|
22357
|
+
const cache = pullFromCache(cacheKey);
|
|
22358
|
+
if (cache) {
|
|
22359
|
+
pushToCache(cacheKey, Object.assign(Object.assign({}, cache), { isDeleted: true }));
|
|
22360
|
+
}
|
|
22361
|
+
}
|
|
22362
|
+
});
|
|
22363
|
+
ingestInCache(data);
|
|
22364
|
+
callbacks$a.forEach(cb => cb(data.channels[0]));
|
|
22365
|
+
};
|
|
22366
|
+
mainDisposer$a = createEventSubscriber(client, 'onChannelDeleted', 'channel.deleted', filter);
|
|
22367
|
+
}
|
|
22368
|
+
callbacks$a.push(callback);
|
|
22369
|
+
return () => dispose$a(callback);
|
|
22370
|
+
};
|
|
22371
|
+
|
|
22372
|
+
const callbacks$9 = [];
|
|
22373
|
+
let mainDisposer$9 = null;
|
|
22374
|
+
const dispose$9 = (cb) => {
|
|
22375
|
+
const index = callbacks$9.indexOf(cb);
|
|
22376
|
+
if (index > -1) {
|
|
22377
|
+
callbacks$9.splice(index, 1);
|
|
22378
|
+
}
|
|
22379
|
+
if (callbacks$9.length === 0) {
|
|
22380
|
+
mainDisposer$9 === null || mainDisposer$9 === void 0 ? void 0 : mainDisposer$9();
|
|
22381
|
+
}
|
|
22382
|
+
};
|
|
22383
|
+
const onChannelJoined = (callback) => {
|
|
22384
|
+
if (callbacks$9.length === 0) {
|
|
22385
|
+
const client = getActiveClient();
|
|
22386
|
+
const filter = async (payload) => {
|
|
22387
|
+
const preparedPayload = await prepareChannelPayload(payload);
|
|
22388
|
+
const { channels, channelUsers } = preparedPayload;
|
|
22389
|
+
ingestInCache(preparedPayload);
|
|
22390
|
+
callbacks$9.forEach(cb => cb(channels[0], channelUsers[0]));
|
|
22391
|
+
};
|
|
22392
|
+
mainDisposer$9 = createEventSubscriber(client, 'onChannelJoined', 'channel.joined', filter);
|
|
22393
|
+
}
|
|
22394
|
+
callbacks$9.push(callback);
|
|
22395
|
+
return () => dispose$9(callback);
|
|
22396
|
+
};
|
|
22397
|
+
|
|
22398
|
+
const callbacks$8 = [];
|
|
22399
|
+
let mainDisposer$8 = null;
|
|
22400
|
+
const dispose$8 = (cb) => {
|
|
22401
|
+
const index = callbacks$8.indexOf(cb);
|
|
22402
|
+
if (index > -1) {
|
|
22403
|
+
callbacks$8.splice(index, 1);
|
|
22404
|
+
}
|
|
22405
|
+
if (callbacks$8.length === 0) {
|
|
22406
|
+
mainDisposer$8 === null || mainDisposer$8 === void 0 ? void 0 : mainDisposer$8();
|
|
22407
|
+
}
|
|
22408
|
+
};
|
|
22409
|
+
const onChannelLeft = (callback) => {
|
|
22410
|
+
if (callbacks$8.length === 0) {
|
|
22411
|
+
const client = getActiveClient();
|
|
22412
|
+
const filter = async (payload) => {
|
|
22413
|
+
const { userId } = getActiveClient();
|
|
22414
|
+
const { channelUsers: leftUsers } = payload;
|
|
22415
|
+
const isLeftByMe = leftUsers.some(user => user.userId === userId);
|
|
22416
|
+
const preparedPayload = await prepareChannelPayload(payload, {
|
|
22417
|
+
isMessagePreviewUpdated: isLeftByMe,
|
|
22418
|
+
});
|
|
22419
|
+
const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
|
|
22420
|
+
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
22421
|
+
if (isLeftByMe) {
|
|
22422
|
+
preparedPayload.channels.forEach(channel => {
|
|
22423
|
+
if (isConsistentMode) {
|
|
22424
|
+
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
22425
|
+
deleteChannelUnreadByChannelId(channel.channelId);
|
|
22426
|
+
}
|
|
22427
|
+
else if (isLegacyUnreadCount) {
|
|
22428
|
+
dropFromCache(['channelUnread', 'get', channel.channelId]);
|
|
22429
|
+
}
|
|
22430
|
+
});
|
|
22431
|
+
}
|
|
22432
|
+
const { channels, channelUsers } = preparedPayload;
|
|
22433
|
+
ingestInCache(preparedPayload);
|
|
22434
|
+
callbacks$8.forEach(cb => cb(channels[0], channelUsers[0]));
|
|
22435
|
+
};
|
|
22436
|
+
mainDisposer$8 = createEventSubscriber(client, 'onChannelLeft', 'channel.left', filter);
|
|
22437
|
+
}
|
|
22438
|
+
callbacks$8.push(callback);
|
|
22439
|
+
return () => dispose$8(callback);
|
|
22440
|
+
};
|
|
22441
|
+
|
|
22442
|
+
const callbacks$7 = [];
|
|
22443
|
+
let mainDisposer$7 = null;
|
|
22444
|
+
const dispose$7 = (cb) => {
|
|
22445
|
+
const index = callbacks$7.indexOf(cb);
|
|
22446
|
+
if (index > -1) {
|
|
22447
|
+
callbacks$7.splice(index, 1);
|
|
22448
|
+
}
|
|
22449
|
+
if (callbacks$7.length === 0) {
|
|
22450
|
+
mainDisposer$7 === null || mainDisposer$7 === void 0 ? void 0 : mainDisposer$7();
|
|
22451
|
+
}
|
|
22452
|
+
};
|
|
22453
|
+
const onChannelSetMuted = (callback) => {
|
|
22454
|
+
if (callbacks$7.length === 0) {
|
|
22455
|
+
const client = getActiveClient();
|
|
22456
|
+
const filter = async (payloads) => {
|
|
22457
|
+
var _a;
|
|
22458
|
+
payloads.forEach(payload => {
|
|
22459
|
+
upsertInCache(['channel', 'get', payload.channelId], {
|
|
22460
|
+
// If muteTimeout > now => user is muted
|
|
22461
|
+
// Otherwise => user is unmuted
|
|
22462
|
+
isMuted: Date.parse(payload.muteTimeout) > Date.now(),
|
|
22463
|
+
});
|
|
22464
|
+
});
|
|
22465
|
+
const channel = (_a = pullFromCache([
|
|
22466
|
+
'channel',
|
|
22467
|
+
'get',
|
|
22468
|
+
payloads[0].channelId,
|
|
22469
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22470
|
+
if (channel) {
|
|
22471
|
+
callbacks$7.forEach(cb => cb(channel));
|
|
22472
|
+
}
|
|
22473
|
+
};
|
|
22474
|
+
mainDisposer$7 = createEventSubscriber(client, 'onChannelMute', 'channel.setMuted', filter);
|
|
22475
|
+
}
|
|
22476
|
+
callbacks$7.push(callback);
|
|
22477
|
+
return () => dispose$7(callback);
|
|
22478
|
+
};
|
|
22479
|
+
|
|
22480
|
+
const callbacks$6 = [];
|
|
22481
|
+
let mainDisposer$6 = null;
|
|
22482
|
+
const dispose$6 = (cb) => {
|
|
22483
|
+
const index = callbacks$6.indexOf(cb);
|
|
22484
|
+
if (index > -1) {
|
|
22485
|
+
callbacks$6.splice(index, 1);
|
|
22486
|
+
}
|
|
22487
|
+
if (callbacks$6.length === 0) {
|
|
22488
|
+
mainDisposer$6 === null || mainDisposer$6 === void 0 ? void 0 : mainDisposer$6();
|
|
22489
|
+
}
|
|
22490
|
+
};
|
|
22491
|
+
const onChannelMemberAdded = (callback) => {
|
|
22492
|
+
if (callbacks$6.length === 0) {
|
|
22493
|
+
const client = getActiveClient();
|
|
22494
|
+
const filter = async (payload) => {
|
|
22495
|
+
const preparedPayload = await prepareChannelPayload(payload);
|
|
22496
|
+
const { channels, channelUsers } = preparedPayload;
|
|
22497
|
+
ingestInCache(preparedPayload);
|
|
22498
|
+
callbacks$6.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'member')));
|
|
22499
|
+
};
|
|
22500
|
+
mainDisposer$6 = createEventSubscriber(client, 'onChannelMemberAdded', 'channel.membersAdded', filter);
|
|
22501
|
+
}
|
|
22502
|
+
callbacks$6.push(callback);
|
|
22503
|
+
return () => dispose$6(callback);
|
|
22504
|
+
};
|
|
22505
|
+
|
|
22506
|
+
const callbacks$5 = [];
|
|
22507
|
+
let mainDisposer$5 = null;
|
|
22508
|
+
const dispose$5 = (cb) => {
|
|
22509
|
+
const index = callbacks$5.indexOf(cb);
|
|
22510
|
+
if (index > -1) {
|
|
22511
|
+
callbacks$5.splice(index, 1);
|
|
22512
|
+
}
|
|
22513
|
+
if (callbacks$5.length === 0) {
|
|
22514
|
+
mainDisposer$5 === null || mainDisposer$5 === void 0 ? void 0 : mainDisposer$5();
|
|
22515
|
+
}
|
|
22516
|
+
};
|
|
22517
|
+
const onChannelMemberRemoved = (callback) => {
|
|
22518
|
+
if (callbacks$5.length === 0) {
|
|
22519
|
+
const client = getActiveClient();
|
|
22520
|
+
const filter = async (payload) => {
|
|
22521
|
+
const preparedPayload = await prepareChannelPayload(payload);
|
|
22522
|
+
const { channels, channelUsers } = preparedPayload;
|
|
22523
|
+
ingestInCache(preparedPayload);
|
|
22524
|
+
callbacks$5.forEach(cb => cb(channels[0], channelUsers[0]));
|
|
22525
|
+
};
|
|
22526
|
+
mainDisposer$5 = createEventSubscriber(client, 'onChannelMemberRemoved', 'channel.membersRemoved', filter);
|
|
22527
|
+
}
|
|
22528
|
+
callbacks$5.push(callback);
|
|
22529
|
+
return () => dispose$5(callback);
|
|
22530
|
+
};
|
|
22531
|
+
|
|
22532
|
+
const callbacks$4 = [];
|
|
22533
|
+
let mainDisposer$4 = null;
|
|
22534
|
+
const dispose$4 = (cb) => {
|
|
22535
|
+
const index = callbacks$4.indexOf(cb);
|
|
22536
|
+
if (index > -1) {
|
|
22537
|
+
callbacks$4.splice(index, 1);
|
|
22538
|
+
}
|
|
22539
|
+
if (callbacks$4.length === 0) {
|
|
22540
|
+
mainDisposer$4 === null || mainDisposer$4 === void 0 ? void 0 : mainDisposer$4();
|
|
22541
|
+
}
|
|
22542
|
+
};
|
|
22543
|
+
const onChannelMemberBanned = (callback) => {
|
|
22544
|
+
const client = getActiveClient();
|
|
22545
|
+
const filter = async (payload) => {
|
|
22546
|
+
const preparedPayload = await prepareChannelPayload(payload);
|
|
22547
|
+
const { channels, channelUsers } = preparedPayload;
|
|
22548
|
+
const isCurrentUserBanned = channelUsers.some(cu => cu.membership === 'banned' && cu.userId === client.userId);
|
|
22549
|
+
if (client.isUnreadCountEnabled &&
|
|
22550
|
+
client.getMarkerSyncConsistentMode() &&
|
|
22551
|
+
isCurrentUserBanned) {
|
|
22552
|
+
preparedPayload.channels.forEach(channel => {
|
|
22553
|
+
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
22554
|
+
deleteChannelUnreadByChannelId(channel.channelId);
|
|
22555
|
+
});
|
|
22556
|
+
}
|
|
22557
|
+
ingestInCache(preparedPayload);
|
|
22558
|
+
callbacks$4.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'banned')));
|
|
22559
|
+
};
|
|
22560
|
+
mainDisposer$4 = createEventSubscriber(client, 'onChannelMemberBanned', 'channel.banned', filter);
|
|
22561
|
+
callbacks$4.push(callback);
|
|
22562
|
+
return () => dispose$4(callback);
|
|
22563
|
+
};
|
|
22564
|
+
|
|
22565
|
+
const callbacks$3 = [];
|
|
22566
|
+
let mainDisposer$3 = null;
|
|
22567
|
+
const dispose$3 = (cb) => {
|
|
22568
|
+
const index = callbacks$3.indexOf(cb);
|
|
22569
|
+
if (index > -1) {
|
|
22570
|
+
callbacks$3.splice(index, 1);
|
|
22571
|
+
}
|
|
22572
|
+
if (callbacks$3.length === 0) {
|
|
22573
|
+
mainDisposer$3 === null || mainDisposer$3 === void 0 ? void 0 : mainDisposer$3();
|
|
22574
|
+
}
|
|
22575
|
+
};
|
|
22576
|
+
const onChannelMemberUnbanned = (callback) => {
|
|
22577
|
+
if (callbacks$3.length === 0) {
|
|
22578
|
+
const client = getActiveClient();
|
|
22579
|
+
const filter = async (payload) => {
|
|
22580
|
+
const preparedPayload = await prepareChannelPayload(payload);
|
|
22581
|
+
const { channels, channelUsers } = preparedPayload;
|
|
22582
|
+
ingestInCache(preparedPayload);
|
|
22583
|
+
callbacks$3.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'none')));
|
|
22584
|
+
};
|
|
22585
|
+
mainDisposer$3 = createEventSubscriber(client, 'onChannelMemberUnbanned', 'channel.unbanned', filter);
|
|
22586
|
+
}
|
|
22587
|
+
callbacks$3.push(callback);
|
|
22588
|
+
return () => dispose$3(callback);
|
|
22589
|
+
};
|
|
22590
|
+
|
|
22591
|
+
const callbacks$2 = [];
|
|
22592
|
+
let mainDisposer$2 = null;
|
|
22593
|
+
const dispose$2 = (cb) => {
|
|
22594
|
+
const index = callbacks$2.indexOf(cb);
|
|
22595
|
+
if (index > -1) {
|
|
22596
|
+
callbacks$2.splice(index, 1);
|
|
22597
|
+
}
|
|
22598
|
+
if (callbacks$2.length === 0) {
|
|
22599
|
+
mainDisposer$2 === null || mainDisposer$2 === void 0 ? void 0 : mainDisposer$2();
|
|
22600
|
+
}
|
|
22601
|
+
};
|
|
22602
|
+
const onChannelMemberRoleAdded = (callback) => {
|
|
22603
|
+
if (callbacks$2.length === 0) {
|
|
22604
|
+
const client = getActiveClient();
|
|
22605
|
+
const filter = async (payload) => {
|
|
22606
|
+
const { channels, channelUsers } = payload;
|
|
22607
|
+
callbacks$2.forEach(cb => cb(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member')));
|
|
22608
|
+
};
|
|
22609
|
+
mainDisposer$2 = createEventSubscriber(client, 'onChannelMemberRoleAdded', 'local.channel-moderator.role-added', filter);
|
|
22610
|
+
}
|
|
22611
|
+
callbacks$2.push(callback);
|
|
22612
|
+
return () => dispose$2(callback);
|
|
22613
|
+
};
|
|
22614
|
+
|
|
22615
|
+
const callbacks$1 = [];
|
|
22616
|
+
let mainDisposer$1 = null;
|
|
22617
|
+
const dispose$1 = (cb) => {
|
|
22618
|
+
const index = callbacks$1.indexOf(cb);
|
|
22619
|
+
if (index > -1) {
|
|
22620
|
+
callbacks$1.splice(index, 1);
|
|
22621
|
+
}
|
|
22622
|
+
if (callbacks$1.length === 0) {
|
|
22623
|
+
mainDisposer$1 === null || mainDisposer$1 === void 0 ? void 0 : mainDisposer$1();
|
|
22624
|
+
}
|
|
22625
|
+
};
|
|
22626
|
+
const onChannelMemberRoleRemoved = (callback) => {
|
|
22627
|
+
if (callbacks$1.length === 0) {
|
|
22628
|
+
const client = getActiveClient();
|
|
22629
|
+
const filter = async (payload) => {
|
|
22630
|
+
const { channels, channelUsers } = payload;
|
|
22631
|
+
callback(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member'));
|
|
22632
|
+
};
|
|
22633
|
+
mainDisposer$1 = createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', filter);
|
|
22634
|
+
}
|
|
22635
|
+
callbacks$1.push(callback);
|
|
22636
|
+
return () => dispose$1(callback);
|
|
22637
|
+
};
|
|
22638
|
+
|
|
22639
|
+
const callbacks = [];
|
|
22640
|
+
let mainDisposer = null;
|
|
22641
|
+
const dispose = (cb) => {
|
|
22642
|
+
const index = callbacks.indexOf(cb);
|
|
22643
|
+
if (index > -1) {
|
|
22644
|
+
callbacks.splice(index, 1);
|
|
22645
|
+
}
|
|
22646
|
+
if (callbacks.length === 0) {
|
|
22647
|
+
mainDisposer === null || mainDisposer === void 0 ? void 0 : mainDisposer();
|
|
22648
|
+
}
|
|
22649
|
+
};
|
|
22650
|
+
const onChannelSetUserMuted = (callback) => {
|
|
22651
|
+
if (callbacks.length === 0) {
|
|
22652
|
+
const client = getActiveClient();
|
|
22653
|
+
const filter = async (payload) => {
|
|
22654
|
+
var _a, _b;
|
|
22655
|
+
payload.userIds.forEach(userId =>
|
|
22656
|
+
// If muteTimeout > now => user is muted
|
|
22657
|
+
// Otherwise => user is unmuted
|
|
22658
|
+
upsertInCache(['channelUsers', 'get', `${payload.channelId}#${userId}`], {
|
|
22659
|
+
isMuted: Date.parse(payload.muteTimeout) > Date.now(),
|
|
22660
|
+
}));
|
|
22661
|
+
const channel = (_a = pullFromCache([
|
|
22662
|
+
'channel',
|
|
22663
|
+
'get',
|
|
22664
|
+
payload.channelId,
|
|
22665
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22666
|
+
const channelUser = (_b = pullFromCache([
|
|
22667
|
+
'channelUsers',
|
|
22668
|
+
'get',
|
|
22669
|
+
`${payload.channelId}#${payload.userIds[0]}`,
|
|
22670
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
22671
|
+
if (channel && channelUser) {
|
|
22672
|
+
callbacks.forEach(cb => cb(channel, channelUser));
|
|
22673
|
+
}
|
|
22674
|
+
};
|
|
22675
|
+
mainDisposer = createEventSubscriber(client, 'onChannelUserMute', 'channel.setMutedUsers', filter);
|
|
22676
|
+
}
|
|
22677
|
+
callbacks.push(callback);
|
|
22678
|
+
return () => dispose(callback);
|
|
22679
|
+
};
|
|
22680
|
+
|
|
22681
|
+
const getMyMembership = (channelId, callback) => {
|
|
22682
|
+
const { _id: userId } = getActiveUser();
|
|
22683
|
+
if (!userId)
|
|
22684
|
+
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
22685
|
+
const { log, cache } = getActiveClient();
|
|
22686
|
+
if (!cache) {
|
|
22687
|
+
console.log('This observable object need the cache data!');
|
|
22688
|
+
}
|
|
22689
|
+
const timestamp = Date.now();
|
|
22690
|
+
log(`liveMymembership(tmpid: ${timestamp}) > listen`);
|
|
22691
|
+
const disposers = [];
|
|
22692
|
+
let isUnsyncedModel = false; // for messages
|
|
22693
|
+
let model;
|
|
22694
|
+
const dispatcher = (data) => {
|
|
22695
|
+
callback(Object.assign(Object.assign({}, data), { data: data.data ? channelMemberLinkedObject(data.data) : data.data }));
|
|
22696
|
+
};
|
|
22697
|
+
const realtimeRouter = (_, __) => {
|
|
22698
|
+
const { data } = getMyMembership$1(channelId);
|
|
22699
|
+
if (isEqual(model, data))
|
|
22700
|
+
return;
|
|
22701
|
+
dispatcher({
|
|
22702
|
+
loading: false,
|
|
22703
|
+
data,
|
|
22704
|
+
});
|
|
22705
|
+
};
|
|
22706
|
+
const onFetch = () => {
|
|
22707
|
+
const query = createQuery(async () => getMyMembership$1(channelId));
|
|
22708
|
+
runQuery(query, ({ error, data, loading, origin, cachedAt }) => {
|
|
22709
|
+
if (cachedAt === UNSYNCED_OBJECT_CACHED_AT_VALUE) {
|
|
22710
|
+
dispatcher({
|
|
22711
|
+
data,
|
|
22712
|
+
origin,
|
|
22713
|
+
loading: false,
|
|
22714
|
+
error: new ASCApiError(UNSYNCED_OBJECT_CACHED_AT_MESSAGE, 800800 /* Amity.ClientError.DISALOOW_UNSYNCED_OBJECT */, "error" /* Amity.ErrorLevel.ERROR */),
|
|
22715
|
+
});
|
|
22716
|
+
isUnsyncedModel = true;
|
|
22717
|
+
disposers.forEach(fn => fn());
|
|
22718
|
+
}
|
|
22719
|
+
else if (!isUnsyncedModel) {
|
|
22720
|
+
dispatcher({ loading, data, origin, error });
|
|
22721
|
+
}
|
|
22722
|
+
if (error) {
|
|
22723
|
+
disposers.forEach(fn => fn());
|
|
22724
|
+
}
|
|
22725
|
+
});
|
|
22726
|
+
};
|
|
22727
|
+
disposers.push(onChannelMemberBanned(realtimeRouter));
|
|
22728
|
+
disposers.push(onChannelMemberUnbanned(realtimeRouter));
|
|
22729
|
+
disposers.push(onChannelSetUserMuted(realtimeRouter));
|
|
22730
|
+
onFetch();
|
|
22731
|
+
return () => {
|
|
22732
|
+
disposers.forEach(fn => fn());
|
|
22733
|
+
};
|
|
22734
|
+
};
|
|
22735
|
+
|
|
22164
22736
|
const channelLinkedObject = (channel) => {
|
|
22165
22737
|
var _a;
|
|
22166
22738
|
let previewMembers = [];
|
|
@@ -22178,6 +22750,7 @@ const channelLinkedObject = (channel) => {
|
|
|
22178
22750
|
return shallowClone(channel, {
|
|
22179
22751
|
markAsRead: () => markAsRead(channel.channelInternalId),
|
|
22180
22752
|
previewMembers,
|
|
22753
|
+
myMembership: (callback) => getMyMembership(channel.channelId, callback),
|
|
22181
22754
|
});
|
|
22182
22755
|
};
|
|
22183
22756
|
|
|
@@ -22804,99 +23377,6 @@ const setClientToken = async (params) => {
|
|
|
22804
23377
|
return { accessToken, users };
|
|
22805
23378
|
};
|
|
22806
23379
|
|
|
22807
|
-
const addFlagIsDeletedSubChannelUnreadByChannelId = (channelId) => {
|
|
22808
|
-
const cacheKey = ['subChannelUnreadInfo', 'get'];
|
|
22809
|
-
const cachedSubChannelUnread = queryCache(cacheKey);
|
|
22810
|
-
if (cachedSubChannelUnread) {
|
|
22811
|
-
const cachedTargetSubChannelUnread = cachedSubChannelUnread === null || cachedSubChannelUnread === void 0 ? void 0 : cachedSubChannelUnread.filter(({ data }) => data.channelId === channelId);
|
|
22812
|
-
cachedTargetSubChannelUnread.forEach(({ key, data }) => {
|
|
22813
|
-
pushToCache(key, Object.assign(Object.assign({}, data), { isDeleted: true }));
|
|
22814
|
-
});
|
|
22815
|
-
}
|
|
22816
|
-
};
|
|
22817
|
-
|
|
22818
|
-
const deleteChannelUnreadByChannelId = (channelId) => {
|
|
22819
|
-
var _a;
|
|
22820
|
-
const channelUnreadInfoCacheKey = ['channelUnreadInfo', 'get', channelId];
|
|
22821
|
-
const channelUnreadInfoCache = (_a = pullFromCache(channelUnreadInfoCacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22822
|
-
if (channelUnreadInfoCache) {
|
|
22823
|
-
dropFromCache(channelUnreadInfoCacheKey);
|
|
22824
|
-
}
|
|
22825
|
-
};
|
|
22826
|
-
|
|
22827
|
-
const callbacks$c = [];
|
|
22828
|
-
let mainDisposer$b = null;
|
|
22829
|
-
const dispose$c = (cb) => {
|
|
22830
|
-
const index = callbacks$c.indexOf(cb);
|
|
22831
|
-
if (index > -1) {
|
|
22832
|
-
callbacks$c.splice(index, 1);
|
|
22833
|
-
}
|
|
22834
|
-
if (callbacks$c.length === 0) {
|
|
22835
|
-
mainDisposer$b === null || mainDisposer$b === void 0 ? void 0 : mainDisposer$b();
|
|
22836
|
-
}
|
|
22837
|
-
};
|
|
22838
|
-
const onChannelDeleted = (callback) => {
|
|
22839
|
-
if (callbacks$c.length === 0) {
|
|
22840
|
-
const client = getActiveClient();
|
|
22841
|
-
const filter = async (payload) => {
|
|
22842
|
-
const data = await prepareChannelPayload(payload);
|
|
22843
|
-
const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
|
|
22844
|
-
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
22845
|
-
data.channels.forEach(channel => {
|
|
22846
|
-
if (isConsistentMode) {
|
|
22847
|
-
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
22848
|
-
deleteChannelUnreadByChannelId(channel.channelId);
|
|
22849
|
-
}
|
|
22850
|
-
else if (isLegacyUnreadCount) {
|
|
22851
|
-
const cacheKey = ['channelUnread', 'get', channel.channelId];
|
|
22852
|
-
const cache = pullFromCache(cacheKey);
|
|
22853
|
-
if (cache) {
|
|
22854
|
-
pushToCache(cacheKey, Object.assign(Object.assign({}, cache), { isDeleted: true }));
|
|
22855
|
-
}
|
|
22856
|
-
}
|
|
22857
|
-
});
|
|
22858
|
-
ingestInCache(data);
|
|
22859
|
-
callbacks$c.forEach(cb => cb(data.channels[0]));
|
|
22860
|
-
};
|
|
22861
|
-
mainDisposer$b = createEventSubscriber(client, 'onChannelDeleted', 'channel.deleted', filter);
|
|
22862
|
-
}
|
|
22863
|
-
callbacks$c.push(callback);
|
|
22864
|
-
return () => dispose$c(callback);
|
|
22865
|
-
};
|
|
22866
|
-
|
|
22867
|
-
const callbacks$b = [];
|
|
22868
|
-
let mainDisposer$a = null;
|
|
22869
|
-
const dispose$b = (cb) => {
|
|
22870
|
-
const index = callbacks$b.indexOf(cb);
|
|
22871
|
-
if (index > -1) {
|
|
22872
|
-
callbacks$b.splice(index, 1);
|
|
22873
|
-
}
|
|
22874
|
-
if (callbacks$b.length === 0) {
|
|
22875
|
-
mainDisposer$a === null || mainDisposer$a === void 0 ? void 0 : mainDisposer$a();
|
|
22876
|
-
}
|
|
22877
|
-
};
|
|
22878
|
-
const onChannelMemberBanned = (callback) => {
|
|
22879
|
-
const client = getActiveClient();
|
|
22880
|
-
const filter = async (payload) => {
|
|
22881
|
-
const preparedPayload = await prepareChannelPayload(payload);
|
|
22882
|
-
const { channels, channelUsers } = preparedPayload;
|
|
22883
|
-
const isCurrentUserBanned = channelUsers.some(cu => cu.membership === 'banned' && cu.userId === client.userId);
|
|
22884
|
-
if (client.isUnreadCountEnabled &&
|
|
22885
|
-
client.getMarkerSyncConsistentMode() &&
|
|
22886
|
-
isCurrentUserBanned) {
|
|
22887
|
-
preparedPayload.channels.forEach(channel => {
|
|
22888
|
-
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
22889
|
-
deleteChannelUnreadByChannelId(channel.channelId);
|
|
22890
|
-
});
|
|
22891
|
-
}
|
|
22892
|
-
ingestInCache(preparedPayload);
|
|
22893
|
-
callbacks$b.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'banned')));
|
|
22894
|
-
};
|
|
22895
|
-
mainDisposer$a = createEventSubscriber(client, 'onChannelMemberBanned', 'channel.banned', filter);
|
|
22896
|
-
callbacks$b.push(callback);
|
|
22897
|
-
return () => dispose$b(callback);
|
|
22898
|
-
};
|
|
22899
|
-
|
|
22900
23380
|
function prepareUserPayload(response) {
|
|
22901
23381
|
return {
|
|
22902
23382
|
users: response.users.map(convertRawUserToInternalUser),
|
|
@@ -24621,291 +25101,6 @@ const accessTokenExpiryWatcher = (sessionHandler) => {
|
|
|
24621
25101
|
return () => clearInterval(interval);
|
|
24622
25102
|
};
|
|
24623
25103
|
|
|
24624
|
-
const callbacks$a = [];
|
|
24625
|
-
let mainDisposer$9 = null;
|
|
24626
|
-
const dispose$a = (cb) => {
|
|
24627
|
-
const index = callbacks$a.indexOf(cb);
|
|
24628
|
-
if (index > -1) {
|
|
24629
|
-
callbacks$a.splice(index, 1);
|
|
24630
|
-
}
|
|
24631
|
-
if (callbacks$a.length === 0) {
|
|
24632
|
-
mainDisposer$9 === null || mainDisposer$9 === void 0 ? void 0 : mainDisposer$9();
|
|
24633
|
-
}
|
|
24634
|
-
};
|
|
24635
|
-
const onChannelCreated = (callback) => {
|
|
24636
|
-
if (callbacks$a.length === 0) {
|
|
24637
|
-
const client = getActiveClient();
|
|
24638
|
-
const filter = async (payload) => {
|
|
24639
|
-
const data = await prepareChannelPayload(payload);
|
|
24640
|
-
ingestInCache(data);
|
|
24641
|
-
callbacks$a.forEach(cb => cb(data.channels[0]));
|
|
24642
|
-
};
|
|
24643
|
-
mainDisposer$9 = createEventSubscriber(client, 'onChannelCreated', 'channel.created', filter);
|
|
24644
|
-
}
|
|
24645
|
-
callbacks$a.push(callback);
|
|
24646
|
-
return () => dispose$a(callback);
|
|
24647
|
-
};
|
|
24648
|
-
|
|
24649
|
-
const callbacks$9 = [];
|
|
24650
|
-
const mainDisposers = [];
|
|
24651
|
-
const dispose$9 = (cb) => {
|
|
24652
|
-
const index = callbacks$9.indexOf(cb);
|
|
24653
|
-
if (index > -1) {
|
|
24654
|
-
callbacks$9.splice(index, 1);
|
|
24655
|
-
}
|
|
24656
|
-
if (callbacks$9.length === 0) {
|
|
24657
|
-
mainDisposers.forEach(fn => fn());
|
|
24658
|
-
}
|
|
24659
|
-
};
|
|
24660
|
-
const onChannelUpdated = (callback) => {
|
|
24661
|
-
const client = getActiveClient();
|
|
24662
|
-
if (callbacks$9.length === 0) {
|
|
24663
|
-
const filter = async (payload) => {
|
|
24664
|
-
const data = await prepareChannelPayload(payload);
|
|
24665
|
-
ingestInCache(data);
|
|
24666
|
-
callbacks$9.forEach(cb => cb(data.channels[0]));
|
|
24667
|
-
};
|
|
24668
|
-
mainDisposers.push(createEventSubscriber(client, 'onChannelUpdated', 'channel.updated', filter));
|
|
24669
|
-
mainDisposers.push(createEventSubscriber(client, 'onChannelUpdated', 'local.channel.updated', payload => callbacks$9.forEach(cb => cb(payload.channels[0]))));
|
|
24670
|
-
}
|
|
24671
|
-
callbacks$9.push(callback);
|
|
24672
|
-
return () => dispose$9(callback);
|
|
24673
|
-
};
|
|
24674
|
-
|
|
24675
|
-
const callbacks$8 = [];
|
|
24676
|
-
let mainDisposer$8 = null;
|
|
24677
|
-
const dispose$8 = (cb) => {
|
|
24678
|
-
const index = callbacks$8.indexOf(cb);
|
|
24679
|
-
if (index > -1) {
|
|
24680
|
-
callbacks$8.splice(index, 1);
|
|
24681
|
-
}
|
|
24682
|
-
if (callbacks$8.length === 0) {
|
|
24683
|
-
mainDisposer$8 === null || mainDisposer$8 === void 0 ? void 0 : mainDisposer$8();
|
|
24684
|
-
}
|
|
24685
|
-
};
|
|
24686
|
-
const onChannelJoined = (callback) => {
|
|
24687
|
-
if (callbacks$8.length === 0) {
|
|
24688
|
-
const client = getActiveClient();
|
|
24689
|
-
const filter = async (payload) => {
|
|
24690
|
-
const preparedPayload = await prepareChannelPayload(payload);
|
|
24691
|
-
const { channels, channelUsers } = preparedPayload;
|
|
24692
|
-
ingestInCache(preparedPayload);
|
|
24693
|
-
callbacks$8.forEach(cb => cb(channels[0], channelUsers[0]));
|
|
24694
|
-
};
|
|
24695
|
-
mainDisposer$8 = createEventSubscriber(client, 'onChannelJoined', 'channel.joined', filter);
|
|
24696
|
-
}
|
|
24697
|
-
callbacks$8.push(callback);
|
|
24698
|
-
return () => dispose$8(callback);
|
|
24699
|
-
};
|
|
24700
|
-
|
|
24701
|
-
const callbacks$7 = [];
|
|
24702
|
-
let mainDisposer$7 = null;
|
|
24703
|
-
const dispose$7 = (cb) => {
|
|
24704
|
-
const index = callbacks$7.indexOf(cb);
|
|
24705
|
-
if (index > -1) {
|
|
24706
|
-
callbacks$7.splice(index, 1);
|
|
24707
|
-
}
|
|
24708
|
-
if (callbacks$7.length === 0) {
|
|
24709
|
-
mainDisposer$7 === null || mainDisposer$7 === void 0 ? void 0 : mainDisposer$7();
|
|
24710
|
-
}
|
|
24711
|
-
};
|
|
24712
|
-
const onChannelLeft = (callback) => {
|
|
24713
|
-
if (callbacks$7.length === 0) {
|
|
24714
|
-
const client = getActiveClient();
|
|
24715
|
-
const filter = async (payload) => {
|
|
24716
|
-
const { userId } = getActiveClient();
|
|
24717
|
-
const { channelUsers: leftUsers } = payload;
|
|
24718
|
-
const isLeftByMe = leftUsers.some(user => user.userId === userId);
|
|
24719
|
-
const preparedPayload = await prepareChannelPayload(payload, {
|
|
24720
|
-
isMessagePreviewUpdated: isLeftByMe,
|
|
24721
|
-
});
|
|
24722
|
-
const isConsistentMode = client.getMarkerSyncConsistentMode() && client.isUnreadCountEnabled;
|
|
24723
|
-
const isLegacyUnreadCount = client.useLegacyUnreadCount;
|
|
24724
|
-
if (isLeftByMe) {
|
|
24725
|
-
preparedPayload.channels.forEach(channel => {
|
|
24726
|
-
if (isConsistentMode) {
|
|
24727
|
-
addFlagIsDeletedSubChannelUnreadByChannelId(channel.channelId);
|
|
24728
|
-
deleteChannelUnreadByChannelId(channel.channelId);
|
|
24729
|
-
}
|
|
24730
|
-
else if (isLegacyUnreadCount) {
|
|
24731
|
-
dropFromCache(['channelUnread', 'get', channel.channelId]);
|
|
24732
|
-
}
|
|
24733
|
-
});
|
|
24734
|
-
}
|
|
24735
|
-
const { channels, channelUsers } = preparedPayload;
|
|
24736
|
-
ingestInCache(preparedPayload);
|
|
24737
|
-
callbacks$7.forEach(cb => cb(channels[0], channelUsers[0]));
|
|
24738
|
-
};
|
|
24739
|
-
mainDisposer$7 = createEventSubscriber(client, 'onChannelLeft', 'channel.left', filter);
|
|
24740
|
-
}
|
|
24741
|
-
callbacks$7.push(callback);
|
|
24742
|
-
return () => dispose$7(callback);
|
|
24743
|
-
};
|
|
24744
|
-
|
|
24745
|
-
const callbacks$6 = [];
|
|
24746
|
-
let mainDisposer$6 = null;
|
|
24747
|
-
const dispose$6 = (cb) => {
|
|
24748
|
-
const index = callbacks$6.indexOf(cb);
|
|
24749
|
-
if (index > -1) {
|
|
24750
|
-
callbacks$6.splice(index, 1);
|
|
24751
|
-
}
|
|
24752
|
-
if (callbacks$6.length === 0) {
|
|
24753
|
-
mainDisposer$6 === null || mainDisposer$6 === void 0 ? void 0 : mainDisposer$6();
|
|
24754
|
-
}
|
|
24755
|
-
};
|
|
24756
|
-
const onChannelSetMuted = (callback) => {
|
|
24757
|
-
if (callbacks$6.length === 0) {
|
|
24758
|
-
const client = getActiveClient();
|
|
24759
|
-
const filter = async (payloads) => {
|
|
24760
|
-
var _a;
|
|
24761
|
-
payloads.forEach(payload => {
|
|
24762
|
-
upsertInCache(['channel', 'get', payload.channelId], {
|
|
24763
|
-
// If muteTimeout > now => user is muted
|
|
24764
|
-
// Otherwise => user is unmuted
|
|
24765
|
-
isMuted: Date.parse(payload.muteTimeout) > Date.now(),
|
|
24766
|
-
});
|
|
24767
|
-
});
|
|
24768
|
-
const channel = (_a = pullFromCache([
|
|
24769
|
-
'channel',
|
|
24770
|
-
'get',
|
|
24771
|
-
payloads[0].channelId,
|
|
24772
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
24773
|
-
if (channel) {
|
|
24774
|
-
callbacks$6.forEach(cb => cb(channel));
|
|
24775
|
-
}
|
|
24776
|
-
};
|
|
24777
|
-
mainDisposer$6 = createEventSubscriber(client, 'onChannelMute', 'channel.setMuted', filter);
|
|
24778
|
-
}
|
|
24779
|
-
callbacks$6.push(callback);
|
|
24780
|
-
return () => dispose$6(callback);
|
|
24781
|
-
};
|
|
24782
|
-
|
|
24783
|
-
const callbacks$5 = [];
|
|
24784
|
-
let mainDisposer$5 = null;
|
|
24785
|
-
const dispose$5 = (cb) => {
|
|
24786
|
-
const index = callbacks$5.indexOf(cb);
|
|
24787
|
-
if (index > -1) {
|
|
24788
|
-
callbacks$5.splice(index, 1);
|
|
24789
|
-
}
|
|
24790
|
-
if (callbacks$5.length === 0) {
|
|
24791
|
-
mainDisposer$5 === null || mainDisposer$5 === void 0 ? void 0 : mainDisposer$5();
|
|
24792
|
-
}
|
|
24793
|
-
};
|
|
24794
|
-
const onChannelMemberAdded = (callback) => {
|
|
24795
|
-
if (callbacks$5.length === 0) {
|
|
24796
|
-
const client = getActiveClient();
|
|
24797
|
-
const filter = async (payload) => {
|
|
24798
|
-
const preparedPayload = await prepareChannelPayload(payload);
|
|
24799
|
-
const { channels, channelUsers } = preparedPayload;
|
|
24800
|
-
ingestInCache(preparedPayload);
|
|
24801
|
-
callbacks$5.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'member')));
|
|
24802
|
-
};
|
|
24803
|
-
mainDisposer$5 = createEventSubscriber(client, 'onChannelMemberAdded', 'channel.membersAdded', filter);
|
|
24804
|
-
}
|
|
24805
|
-
callbacks$5.push(callback);
|
|
24806
|
-
return () => dispose$5(callback);
|
|
24807
|
-
};
|
|
24808
|
-
|
|
24809
|
-
const callbacks$4 = [];
|
|
24810
|
-
let mainDisposer$4 = null;
|
|
24811
|
-
const dispose$4 = (cb) => {
|
|
24812
|
-
const index = callbacks$4.indexOf(cb);
|
|
24813
|
-
if (index > -1) {
|
|
24814
|
-
callbacks$4.splice(index, 1);
|
|
24815
|
-
}
|
|
24816
|
-
if (callbacks$4.length === 0) {
|
|
24817
|
-
mainDisposer$4 === null || mainDisposer$4 === void 0 ? void 0 : mainDisposer$4();
|
|
24818
|
-
}
|
|
24819
|
-
};
|
|
24820
|
-
const onChannelMemberRemoved = (callback) => {
|
|
24821
|
-
if (callbacks$4.length === 0) {
|
|
24822
|
-
const client = getActiveClient();
|
|
24823
|
-
const filter = async (payload) => {
|
|
24824
|
-
const preparedPayload = await prepareChannelPayload(payload);
|
|
24825
|
-
const { channels, channelUsers } = preparedPayload;
|
|
24826
|
-
ingestInCache(preparedPayload);
|
|
24827
|
-
callbacks$4.forEach(cb => cb(channels[0], channelUsers[0]));
|
|
24828
|
-
};
|
|
24829
|
-
mainDisposer$4 = createEventSubscriber(client, 'onChannelMemberRemoved', 'channel.membersRemoved', filter);
|
|
24830
|
-
}
|
|
24831
|
-
callbacks$4.push(callback);
|
|
24832
|
-
return () => dispose$4(callback);
|
|
24833
|
-
};
|
|
24834
|
-
|
|
24835
|
-
const callbacks$3 = [];
|
|
24836
|
-
let mainDisposer$3 = null;
|
|
24837
|
-
const dispose$3 = (cb) => {
|
|
24838
|
-
const index = callbacks$3.indexOf(cb);
|
|
24839
|
-
if (index > -1) {
|
|
24840
|
-
callbacks$3.splice(index, 1);
|
|
24841
|
-
}
|
|
24842
|
-
if (callbacks$3.length === 0) {
|
|
24843
|
-
mainDisposer$3 === null || mainDisposer$3 === void 0 ? void 0 : mainDisposer$3();
|
|
24844
|
-
}
|
|
24845
|
-
};
|
|
24846
|
-
const onChannelMemberUnbanned = (callback) => {
|
|
24847
|
-
if (callbacks$3.length === 0) {
|
|
24848
|
-
const client = getActiveClient();
|
|
24849
|
-
const filter = async (payload) => {
|
|
24850
|
-
const preparedPayload = await prepareChannelPayload(payload);
|
|
24851
|
-
const { channels, channelUsers } = preparedPayload;
|
|
24852
|
-
ingestInCache(preparedPayload);
|
|
24853
|
-
callbacks$3.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'none')));
|
|
24854
|
-
};
|
|
24855
|
-
mainDisposer$3 = createEventSubscriber(client, 'onChannelMemberUnbanned', 'channel.unbanned', filter);
|
|
24856
|
-
}
|
|
24857
|
-
callbacks$3.push(callback);
|
|
24858
|
-
return () => dispose$3(callback);
|
|
24859
|
-
};
|
|
24860
|
-
|
|
24861
|
-
const callbacks$2 = [];
|
|
24862
|
-
let mainDisposer$2 = null;
|
|
24863
|
-
const dispose$2 = (cb) => {
|
|
24864
|
-
const index = callbacks$2.indexOf(cb);
|
|
24865
|
-
if (index > -1) {
|
|
24866
|
-
callbacks$2.splice(index, 1);
|
|
24867
|
-
}
|
|
24868
|
-
if (callbacks$2.length === 0) {
|
|
24869
|
-
mainDisposer$2 === null || mainDisposer$2 === void 0 ? void 0 : mainDisposer$2();
|
|
24870
|
-
}
|
|
24871
|
-
};
|
|
24872
|
-
const onChannelMemberRoleAdded = (callback) => {
|
|
24873
|
-
if (callbacks$2.length === 0) {
|
|
24874
|
-
const client = getActiveClient();
|
|
24875
|
-
const filter = async (payload) => {
|
|
24876
|
-
const { channels, channelUsers } = payload;
|
|
24877
|
-
callbacks$2.forEach(cb => cb(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member')));
|
|
24878
|
-
};
|
|
24879
|
-
mainDisposer$2 = createEventSubscriber(client, 'onChannelMemberRoleAdded', 'local.channel-moderator.role-added', filter);
|
|
24880
|
-
}
|
|
24881
|
-
callbacks$2.push(callback);
|
|
24882
|
-
return () => dispose$2(callback);
|
|
24883
|
-
};
|
|
24884
|
-
|
|
24885
|
-
const callbacks$1 = [];
|
|
24886
|
-
let mainDisposer$1 = null;
|
|
24887
|
-
const dispose$1 = (cb) => {
|
|
24888
|
-
const index = callbacks$1.indexOf(cb);
|
|
24889
|
-
if (index > -1) {
|
|
24890
|
-
callbacks$1.splice(index, 1);
|
|
24891
|
-
}
|
|
24892
|
-
if (callbacks$1.length === 0) {
|
|
24893
|
-
mainDisposer$1 === null || mainDisposer$1 === void 0 ? void 0 : mainDisposer$1();
|
|
24894
|
-
}
|
|
24895
|
-
};
|
|
24896
|
-
const onChannelMemberRoleRemoved = (callback) => {
|
|
24897
|
-
if (callbacks$1.length === 0) {
|
|
24898
|
-
const client = getActiveClient();
|
|
24899
|
-
const filter = async (payload) => {
|
|
24900
|
-
const { channels, channelUsers } = payload;
|
|
24901
|
-
callback(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member'));
|
|
24902
|
-
};
|
|
24903
|
-
mainDisposer$1 = createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', filter);
|
|
24904
|
-
}
|
|
24905
|
-
callbacks$1.push(callback);
|
|
24906
|
-
return () => dispose$1(callback);
|
|
24907
|
-
};
|
|
24908
|
-
|
|
24909
25104
|
/**
|
|
24910
25105
|
* ```js
|
|
24911
25106
|
* import { onFeedMarkerUpdated } from '@amityco/ts-sdk'
|
|
@@ -25890,76 +26085,6 @@ const onMessageMarked = (callback) => {
|
|
|
25890
26085
|
return createEventSubscriber(client, 'messageMarker/onMessageMarked', 'marker.marked-message', filter);
|
|
25891
26086
|
};
|
|
25892
26087
|
|
|
25893
|
-
/**
|
|
25894
|
-
* ```js
|
|
25895
|
-
* import { isEqual } from '~/utils/isEqual'
|
|
25896
|
-
* const isEqual = isEqual(post1, post2)
|
|
25897
|
-
* ```
|
|
25898
|
-
*
|
|
25899
|
-
* Compares two Amity.Model
|
|
25900
|
-
*
|
|
25901
|
-
* @param x the Amity.Model to compare
|
|
25902
|
-
* @param y the Amity.Model to compare wit x
|
|
25903
|
-
* @returns a boolean based on equality
|
|
25904
|
-
*
|
|
25905
|
-
* @category utility
|
|
25906
|
-
* @private
|
|
25907
|
-
*/
|
|
25908
|
-
function isEqual(x, y) {
|
|
25909
|
-
if (x === null || x === undefined || y === null || y === undefined) {
|
|
25910
|
-
return x === y;
|
|
25911
|
-
}
|
|
25912
|
-
// after this just checking type of one would be enough
|
|
25913
|
-
if (x.constructor !== y.constructor) {
|
|
25914
|
-
return false;
|
|
25915
|
-
}
|
|
25916
|
-
// if they are functions, they should exactly refer to same one (because of closures)
|
|
25917
|
-
if (x instanceof Function) {
|
|
25918
|
-
return x === y;
|
|
25919
|
-
}
|
|
25920
|
-
// if they are regexps, they should exactly refer to same one
|
|
25921
|
-
if (x instanceof RegExp) {
|
|
25922
|
-
return x === y;
|
|
25923
|
-
}
|
|
25924
|
-
if (x === y || x.valueOf() === y.valueOf()) {
|
|
25925
|
-
return true;
|
|
25926
|
-
}
|
|
25927
|
-
if (Array.isArray(x) && x.length !== y.length) {
|
|
25928
|
-
return false;
|
|
25929
|
-
}
|
|
25930
|
-
// check each element of the array for equality
|
|
25931
|
-
if (Array.isArray(x) && Array.isArray(y)) {
|
|
25932
|
-
if (x.length !== y.length)
|
|
25933
|
-
return false;
|
|
25934
|
-
for (let i = 0; i < x.length; i += 1) {
|
|
25935
|
-
if (!isEqual(x[i], y[i]))
|
|
25936
|
-
return false;
|
|
25937
|
-
}
|
|
25938
|
-
// if all elements are equal, the arrays are equal
|
|
25939
|
-
return true;
|
|
25940
|
-
}
|
|
25941
|
-
// if they are dates, they must had equal valueOf
|
|
25942
|
-
if (x instanceof Date) {
|
|
25943
|
-
return false;
|
|
25944
|
-
}
|
|
25945
|
-
// if they are strictly equal, they both need to be object at least
|
|
25946
|
-
if (!(x instanceof Object)) {
|
|
25947
|
-
return false;
|
|
25948
|
-
}
|
|
25949
|
-
if (!(y instanceof Object)) {
|
|
25950
|
-
return false;
|
|
25951
|
-
}
|
|
25952
|
-
// recursive object equality check
|
|
25953
|
-
const p = Object.keys(x);
|
|
25954
|
-
return (Object.keys(y).every(i => {
|
|
25955
|
-
// @ts-ignore
|
|
25956
|
-
return p.indexOf(i) !== -1;
|
|
25957
|
-
}) &&
|
|
25958
|
-
p.every(i => {
|
|
25959
|
-
return isEqual(x[i], y[i]);
|
|
25960
|
-
}));
|
|
25961
|
-
}
|
|
25962
|
-
|
|
25963
26088
|
function isObject(value) {
|
|
25964
26089
|
return typeof value === 'object' && value !== null;
|
|
25965
26090
|
}
|
|
@@ -35677,50 +35802,6 @@ const onUserDeleted$1 = (channelId) => (callback) => {
|
|
|
35677
35802
|
return createEventSubscriber(client, 'user.deleted', 'user.deleted', filter);
|
|
35678
35803
|
};
|
|
35679
35804
|
|
|
35680
|
-
const callbacks = [];
|
|
35681
|
-
let mainDisposer = null;
|
|
35682
|
-
const dispose = (cb) => {
|
|
35683
|
-
const index = callbacks.indexOf(cb);
|
|
35684
|
-
if (index > -1) {
|
|
35685
|
-
callbacks.splice(index, 1);
|
|
35686
|
-
}
|
|
35687
|
-
if (callbacks.length === 0) {
|
|
35688
|
-
mainDisposer === null || mainDisposer === void 0 ? void 0 : mainDisposer();
|
|
35689
|
-
}
|
|
35690
|
-
};
|
|
35691
|
-
const onChannelSetUserMuted = (callback) => {
|
|
35692
|
-
if (callbacks.length === 0) {
|
|
35693
|
-
const client = getActiveClient();
|
|
35694
|
-
const filter = async (payloads) => {
|
|
35695
|
-
var _a, _b;
|
|
35696
|
-
payloads.forEach(payload => {
|
|
35697
|
-
payload.userIds.forEach(userId =>
|
|
35698
|
-
// If muteTimeout > now => user is muted
|
|
35699
|
-
// Otherwise => user is unmuted
|
|
35700
|
-
upsertInCache(['channelUsers', 'get', `${payload.channelId}#${userId}`], {
|
|
35701
|
-
isMuted: Date.parse(payload.muteTimeout) > Date.now(),
|
|
35702
|
-
}));
|
|
35703
|
-
});
|
|
35704
|
-
const channel = (_a = pullFromCache([
|
|
35705
|
-
'channel',
|
|
35706
|
-
'get',
|
|
35707
|
-
payloads[0].channelId,
|
|
35708
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
35709
|
-
const channelUser = (_b = pullFromCache([
|
|
35710
|
-
'channelUsers',
|
|
35711
|
-
'get',
|
|
35712
|
-
`${payloads[0].channelId}#${payloads[0].userIds[0]}`,
|
|
35713
|
-
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
35714
|
-
if (channel && channelUser) {
|
|
35715
|
-
callbacks.forEach(cb => cb(channel, channelUser));
|
|
35716
|
-
}
|
|
35717
|
-
};
|
|
35718
|
-
mainDisposer = createEventSubscriber(client, 'onChannelUserMute', 'channel.setUserMuted', filter);
|
|
35719
|
-
}
|
|
35720
|
-
callbacks.push(callback);
|
|
35721
|
-
return () => dispose(callback);
|
|
35722
|
-
};
|
|
35723
|
-
|
|
35724
35805
|
/* eslint-disable no-use-before-define */
|
|
35725
35806
|
class ChannelMemberLiveCollectionController extends LiveCollectionController {
|
|
35726
35807
|
constructor(query, callback) {
|
|
@@ -41941,6 +42022,39 @@ const onStreamTerminated = (callback) => {
|
|
|
41941
42022
|
return createEventSubscriber(client, 'stream/onStreamTerminated', 'video-streaming.didTerminate', filter);
|
|
41942
42023
|
};
|
|
41943
42024
|
|
|
42025
|
+
/**
|
|
42026
|
+
* ```js
|
|
42027
|
+
* import { onStreamViewerUnbanned } from '@amityco/ts-sdk'
|
|
42028
|
+
* const dispose = onStreamViewerBanned(stream => {
|
|
42029
|
+
* // ...
|
|
42030
|
+
* })
|
|
42031
|
+
* ```
|
|
42032
|
+
*
|
|
42033
|
+
* Fired when a user in channel linked to stream has been unbanned
|
|
42034
|
+
*
|
|
42035
|
+
* @param callback The function to call when the event was fired
|
|
42036
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
42037
|
+
*
|
|
42038
|
+
* @category Stream Events
|
|
42039
|
+
*/
|
|
42040
|
+
const onStreamViewerUnbanned = (callback) => {
|
|
42041
|
+
const client = getActiveClient();
|
|
42042
|
+
const filter = async (payloads) => {
|
|
42043
|
+
var _a;
|
|
42044
|
+
// Get new stream object to restore stream watcherUrl in cache
|
|
42045
|
+
await Promise.all(payloads.map(({ streamId }) => getStream(streamId)));
|
|
42046
|
+
const stream = (_a = pullFromCache([
|
|
42047
|
+
'stream',
|
|
42048
|
+
'get',
|
|
42049
|
+
payloads[0].streamId,
|
|
42050
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
42051
|
+
if (!stream)
|
|
42052
|
+
return;
|
|
42053
|
+
callback(stream);
|
|
42054
|
+
};
|
|
42055
|
+
return createEventSubscriber(client, 'stream/onStreamViewerDidUnban', 'video-streaming.viewerDidUnban', filter);
|
|
42056
|
+
};
|
|
42057
|
+
|
|
41944
42058
|
/* eslint-disable no-use-before-define */
|
|
41945
42059
|
/* begin_public_function
|
|
41946
42060
|
id: stream.get
|
|
@@ -42059,39 +42173,6 @@ class GetStreamsQueryStreamController extends QueryStreamController {
|
|
|
42059
42173
|
}
|
|
42060
42174
|
}
|
|
42061
42175
|
|
|
42062
|
-
/**
|
|
42063
|
-
* ```js
|
|
42064
|
-
* import { onStreamViewerUnbanned } from '@amityco/ts-sdk'
|
|
42065
|
-
* const dispose = onStreamViewerBanned(stream => {
|
|
42066
|
-
* // ...
|
|
42067
|
-
* })
|
|
42068
|
-
* ```
|
|
42069
|
-
*
|
|
42070
|
-
* Fired when a user in channel linked to stream has been unbanned
|
|
42071
|
-
*
|
|
42072
|
-
* @param callback The function to call when the event was fired
|
|
42073
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
42074
|
-
*
|
|
42075
|
-
* @category Stream Events
|
|
42076
|
-
*/
|
|
42077
|
-
const onStreamViewerUnbanned = (callback) => {
|
|
42078
|
-
const client = getActiveClient();
|
|
42079
|
-
const filter = async (payloads) => {
|
|
42080
|
-
var _a;
|
|
42081
|
-
// Get new stream object to restore stream watcherUrl in cache
|
|
42082
|
-
await Promise.all(payloads.map(({ streamId }) => getStream(streamId)));
|
|
42083
|
-
const stream = (_a = pullFromCache([
|
|
42084
|
-
'stream',
|
|
42085
|
-
'get',
|
|
42086
|
-
payloads[0].streamId,
|
|
42087
|
-
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
42088
|
-
if (!stream)
|
|
42089
|
-
return;
|
|
42090
|
-
callback(stream);
|
|
42091
|
-
};
|
|
42092
|
-
return createEventSubscriber(client, 'stream/onStreamViewerDidUnban', 'video-streaming.viewerDidUnban', filter);
|
|
42093
|
-
};
|
|
42094
|
-
|
|
42095
42176
|
class GetStreamsLiveCollectionController extends LiveCollectionController {
|
|
42096
42177
|
constructor(query, callback) {
|
|
42097
42178
|
const queryStreamId = hash(query);
|
|
@@ -42189,6 +42270,8 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
42189
42270
|
onStreamRecorded: onStreamRecorded,
|
|
42190
42271
|
onStreamFlagged: onStreamFlagged,
|
|
42191
42272
|
onStreamTerminated: onStreamTerminated,
|
|
42273
|
+
onStreamViewerBanned: onStreamViewerBanned,
|
|
42274
|
+
onStreamViewerUnbanned: onStreamViewerUnbanned,
|
|
42192
42275
|
getStreamById: getStreamById,
|
|
42193
42276
|
getStreams: getStreams
|
|
42194
42277
|
});
|
|
@@ -42689,7 +42772,8 @@ const USAGE_COLLECTION_INTERVAL = 20 * SECOND;
|
|
|
42689
42772
|
* 2. Get the usage collector instance to update usage
|
|
42690
42773
|
*/
|
|
42691
42774
|
class EventRegister {
|
|
42692
|
-
constructor(player, resolution) {
|
|
42775
|
+
constructor(player, resolution, streamId) {
|
|
42776
|
+
this._SDKUnsubscribers = [];
|
|
42693
42777
|
this.player = player;
|
|
42694
42778
|
this.resolution = resolution;
|
|
42695
42779
|
this._startTime = null;
|
|
@@ -42706,10 +42790,20 @@ class EventRegister {
|
|
|
42706
42790
|
mutation.removedNodes.forEach(node => {
|
|
42707
42791
|
if (node === player) {
|
|
42708
42792
|
this._unregisterEvents();
|
|
42793
|
+
this._SDKUnsubscribers.forEach(fn => fn === null || fn === void 0 ? void 0 : fn());
|
|
42709
42794
|
}
|
|
42710
42795
|
});
|
|
42711
42796
|
});
|
|
42712
42797
|
});
|
|
42798
|
+
this._SDKUnsubscribers.push(onStreamViewerBanned(stream => {
|
|
42799
|
+
// if still has stream.watcherUrl, the current user has not banned.
|
|
42800
|
+
if (stream.watcherUrl)
|
|
42801
|
+
return;
|
|
42802
|
+
this.player.pause();
|
|
42803
|
+
this.player.removeAttribute('src');
|
|
42804
|
+
this.player.load();
|
|
42805
|
+
this.player.remove();
|
|
42806
|
+
}));
|
|
42713
42807
|
}
|
|
42714
42808
|
_resetStartTime() {
|
|
42715
42809
|
this._startTime = Date.now();
|
|
@@ -42832,7 +42926,7 @@ const getPlayer = async (parameters) => {
|
|
|
42832
42926
|
}
|
|
42833
42927
|
video.src = recording.mp4.url;
|
|
42834
42928
|
}
|
|
42835
|
-
new EventRegister(video, resolution).registerEvents();
|
|
42929
|
+
new EventRegister(video, resolution, streamId).registerEvents();
|
|
42836
42930
|
return video;
|
|
42837
42931
|
};
|
|
42838
42932
|
|