@stream-io/video-react-sdk 1.10.6 → 1.11.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/index.es.js CHANGED
@@ -2251,6 +2251,56 @@ const StreamVideo = (props) => {
2251
2251
  };
2252
2252
  StreamVideo.displayName = 'StreamVideo';
2253
2253
 
2254
+ function applyFilter(obj, filter) {
2255
+ if ('$and' in filter) {
2256
+ return filter.$and.every((f) => applyFilter(obj, f));
2257
+ }
2258
+ if ('$or' in filter) {
2259
+ return filter.$or.some((f) => applyFilter(obj, f));
2260
+ }
2261
+ if ('$not' in filter) {
2262
+ return !applyFilter(obj, filter.$not);
2263
+ }
2264
+ return checkConditions(obj, filter);
2265
+ }
2266
+ function checkConditions(obj, conditions) {
2267
+ let match = true;
2268
+ for (const key of Object.keys(conditions)) {
2269
+ const operator = conditions[key];
2270
+ const maybeOperator = operator && typeof operator === 'object';
2271
+ let value = obj[key];
2272
+ if (maybeOperator && '$eq' in operator) {
2273
+ const eqOperator = operator;
2274
+ match && (match = eqOperator.$eq === value);
2275
+ }
2276
+ else if (maybeOperator && '$neq' in operator) {
2277
+ const neqOperator = operator;
2278
+ match && (match = neqOperator.$neq !== value);
2279
+ }
2280
+ else if (maybeOperator && '$in' in operator) {
2281
+ const inOperator = operator;
2282
+ match && (match = inOperator.$in.includes(value));
2283
+ }
2284
+ else if (maybeOperator && '$contains' in operator) {
2285
+ if (Array.isArray(value)) {
2286
+ const containsOperator = operator;
2287
+ match && (match = value.includes(containsOperator.$contains));
2288
+ }
2289
+ else {
2290
+ match = false;
2291
+ }
2292
+ }
2293
+ else {
2294
+ const eqValue = operator;
2295
+ match && (match = eqValue === value);
2296
+ }
2297
+ if (!match) {
2298
+ return false;
2299
+ }
2300
+ }
2301
+ return true;
2302
+ }
2303
+
2254
2304
  const useFilteredParticipants = ({ excludeLocalParticipant = false, filterParticipants, }) => {
2255
2305
  const { useParticipants, useRemoteParticipants } = useCallStateHooks();
2256
2306
  const allParticipants = useParticipants();
@@ -2260,7 +2310,7 @@ const useFilteredParticipants = ({ excludeLocalParticipant = false, filterPartic
2260
2310
  ? remoteParticipants
2261
2311
  : allParticipants;
2262
2312
  return filterParticipants
2263
- ? unfilteredParticipants.filter((participant) => filterParticipants(participant))
2313
+ ? applyParticipantsFilter(unfilteredParticipants, filterParticipants)
2264
2314
  : unfilteredParticipants;
2265
2315
  }, [
2266
2316
  allParticipants,
@@ -2269,6 +2319,19 @@ const useFilteredParticipants = ({ excludeLocalParticipant = false, filterPartic
2269
2319
  filterParticipants,
2270
2320
  ]);
2271
2321
  };
2322
+ const applyParticipantsFilter = (participants, filter) => {
2323
+ const filterCallback = typeof filter === 'function'
2324
+ ? filter
2325
+ : (participant) => applyFilter({
2326
+ userId: participant.userId,
2327
+ isSpeaking: participant.isSpeaking,
2328
+ isDominantSpeaker: participant.isDominantSpeaker,
2329
+ name: participant.name,
2330
+ roles: participant.roles,
2331
+ isPinned: isPinned(participant),
2332
+ }, filter);
2333
+ return participants.filter(filterCallback);
2334
+ };
2272
2335
  const usePaginatedLayoutSortPreset = (call) => {
2273
2336
  useEffect(() => {
2274
2337
  if (!call)
@@ -2576,7 +2639,7 @@ const LivestreamPlayer = (props) => {
2576
2639
  return (jsx(StreamCall, { call: call, children: jsx(LivestreamLayout, { ...layoutProps }) }));
2577
2640
  };
2578
2641
 
2579
- const [major, minor, patch] = ("1.10.6").split('.');
2642
+ const [major, minor, patch] = ("1.11.0").split('.');
2580
2643
  setSdkInfo({
2581
2644
  type: SfuModels.SdkType.REACT,
2582
2645
  major,