@optifye/dashboard-core 6.11.34 → 6.11.35

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.js CHANGED
@@ -37447,6 +37447,14 @@ var formatTimestampRange = (startTime, endTime, timezone) => {
37447
37447
  });
37448
37448
  return `${startFormatted} - ${endFormatted}`;
37449
37449
  };
37450
+ var buildPrefetchedExplorerMetadata = (activeFilter, metadataCategoryId, categoryMetadata) => {
37451
+ if (!activeFilter || !metadataCategoryId || metadataCategoryId !== activeFilter || categoryMetadata.length === 0) {
37452
+ return void 0;
37453
+ }
37454
+ return {
37455
+ [activeFilter]: categoryMetadata
37456
+ };
37457
+ };
37450
37458
  var getSecondsBetweenTimestamps = (startTime, endTime) => {
37451
37459
  const startDate = parseTimestamp(startTime);
37452
37460
  const endDate = parseTimestamp(endTime);
@@ -42644,6 +42652,7 @@ var BottlenecksContent = ({
42644
42652
  const [error, setError] = React143.useState(null);
42645
42653
  const [clipClassifications, setClipClassifications] = React143.useState({});
42646
42654
  const [categoryMetadata, setCategoryMetadata] = React143.useState([]);
42655
+ const [categoryMetadataCategoryId, setCategoryMetadataCategoryId] = React143.useState(null);
42647
42656
  const [currentMetadataIndex, setCurrentMetadataIndex] = React143.useState(0);
42648
42657
  const [metadataCache, setMetadataCache] = React143.useState({});
42649
42658
  const invalidateMetadataCache = React143.useCallback((categories) => {
@@ -43115,6 +43124,15 @@ var BottlenecksContent = ({
43115
43124
  const getMetadataCacheKey = React143.useCallback((categoryId) => {
43116
43125
  return `${categoryId}-${effectiveDateString}-${effectiveShiftId}-${snapshotDateTime ?? "nosnap"}-${snapshotClipId ?? "nosnap"}`;
43117
43126
  }, [effectiveDateString, effectiveShiftId, snapshotDateTime, snapshotClipId]);
43127
+ const setVisibleCategoryMetadata = React143.useCallback((categoryId, clips) => {
43128
+ if (activeFilterRef.current !== categoryId) {
43129
+ return false;
43130
+ }
43131
+ categoryMetadataRef.current = clips;
43132
+ setCategoryMetadata(clips);
43133
+ setCategoryMetadataCategoryId(clips.length > 0 ? categoryId : null);
43134
+ return true;
43135
+ }, []);
43118
43136
  const applyMetadataSnapshot = React143.useCallback((categoryId, clips, total) => {
43119
43137
  if (!clips || clips.length === 0) {
43120
43138
  return;
@@ -43124,13 +43142,12 @@ var BottlenecksContent = ({
43124
43142
  ...prev,
43125
43143
  [cacheKey]: clips
43126
43144
  }));
43127
- categoryMetadataRef.current = clips;
43128
- setCategoryMetadata(clips);
43145
+ setVisibleCategoryMetadata(categoryId, clips);
43129
43146
  if (!isPercentileCategory(categoryId) && typeof total === "number") {
43130
43147
  currentTotalRef.current = total;
43131
43148
  setCurrentTotal(total);
43132
43149
  }
43133
- }, [getMetadataCacheKey, isPercentileCategory]);
43150
+ }, [getMetadataCacheKey, isPercentileCategory, setVisibleCategoryMetadata]);
43134
43151
  const getClipTypesForPercentileCategory = React143.useCallback((categoryId) => {
43135
43152
  switch (categoryId) {
43136
43153
  case "fast-cycles":
@@ -43155,6 +43172,7 @@ var BottlenecksContent = ({
43155
43172
  return;
43156
43173
  }
43157
43174
  setCategoryMetadata([]);
43175
+ setCategoryMetadataCategoryId(null);
43158
43176
  categoryMetadataRef.current = [];
43159
43177
  updateActiveFilter(fallbackFilter);
43160
43178
  }, [isFastSlowClipFiltersEnabled, activeFilter, dynamicCounts, clipTypes, updateActiveFilter]);
@@ -43201,6 +43219,7 @@ var BottlenecksContent = ({
43201
43219
  }
43202
43220
  if (!isFastSlowClipFiltersEnabled && (categoryId === "fast-cycles" || categoryId === "slow-cycles")) {
43203
43221
  setCategoryMetadata([]);
43222
+ setCategoryMetadataCategoryId(null);
43204
43223
  categoryMetadataRef.current = [];
43205
43224
  return;
43206
43225
  }
@@ -43214,8 +43233,7 @@ var BottlenecksContent = ({
43214
43233
  try {
43215
43234
  if (cachedMetadata) {
43216
43235
  console.log(`[BottlenecksContent] Using cached metadata for ${categoryId}`);
43217
- setCategoryMetadata(cachedMetadata);
43218
- categoryMetadataRef.current = cachedMetadata;
43236
+ setVisibleCategoryMetadata(categoryId, cachedMetadata);
43219
43237
  if (autoLoadFirstVideo && cachedMetadata.length > 0 && s3ClipsService) {
43220
43238
  const firstClipMeta = cachedMetadata[0];
43221
43239
  try {
@@ -43329,8 +43347,7 @@ var BottlenecksContent = ({
43329
43347
  ...prev,
43330
43348
  [cacheKey]: metadataClips
43331
43349
  }));
43332
- setCategoryMetadata(metadataClips);
43333
- categoryMetadataRef.current = metadataClips;
43350
+ setVisibleCategoryMetadata(categoryId, metadataClips);
43334
43351
  console.log(`[BottlenecksContent] Loaded metadata for ${categoryId}: ${metadataClips.length} clips`);
43335
43352
  if (autoLoadFirstVideo && metadataClips.length > 0 && s3ClipsService) {
43336
43353
  const firstClipMeta = metadataClips[0];
@@ -43349,15 +43366,18 @@ var BottlenecksContent = ({
43349
43366
  }
43350
43367
  }
43351
43368
  } else {
43352
- setCategoryMetadata([]);
43353
- categoryMetadataRef.current = [];
43369
+ if (activeFilterRef.current === categoryId) {
43370
+ setCategoryMetadata([]);
43371
+ setCategoryMetadataCategoryId(null);
43372
+ categoryMetadataRef.current = [];
43373
+ }
43354
43374
  }
43355
43375
  } catch (error2) {
43356
43376
  console.error(`[BottlenecksContent] Error loading category metadata:`, error2);
43357
43377
  } finally {
43358
43378
  setIsCategoryLoading(false);
43359
43379
  }
43360
- }, [workspaceId, effectiveDateString, effectiveShiftId, getMetadataCacheKey, isPercentileCategory, isFastSlowClipFiltersEnabled, metadataCache, s3ClipsService, clearLoadingState, isEffectiveShiftReady, snapshotDateTime, snapshotClipId, supabase]);
43380
+ }, [workspaceId, effectiveDateString, effectiveShiftId, getMetadataCacheKey, isPercentileCategory, isFastSlowClipFiltersEnabled, metadataCache, s3ClipsService, clearLoadingState, isEffectiveShiftReady, snapshotDateTime, snapshotClipId, supabase, setVisibleCategoryMetadata]);
43361
43381
  React143.useEffect(() => {
43362
43382
  if (previousFilterRef.current !== activeFilter) {
43363
43383
  console.log(`Filter changed from ${previousFilterRef.current} to ${activeFilter} - resetting to first video`);
@@ -43367,6 +43387,7 @@ var BottlenecksContent = ({
43367
43387
  setIsNavigating(false);
43368
43388
  loadingCategoryRef.current = null;
43369
43389
  setCategoryMetadata([]);
43390
+ setCategoryMetadataCategoryId(null);
43370
43391
  setCurrentMetadataIndex(0);
43371
43392
  categoryMetadataRef.current = [];
43372
43393
  currentMetadataIndexRef.current = 0;
@@ -43925,14 +43946,11 @@ var BottlenecksContent = ({
43925
43946
  }
43926
43947
  return currentPosition;
43927
43948
  }, [activeFilter, categoryMetadata.length, currentMetadataIndex, currentPosition, isPercentileCategory]);
43928
- const prefetchedExplorerMetadata = React143.useMemo(() => {
43929
- if (!activeFilter || categoryMetadata.length === 0) {
43930
- return void 0;
43931
- }
43932
- return {
43933
- [activeFilter]: categoryMetadata
43934
- };
43935
- }, [activeFilter, categoryMetadata]);
43949
+ const prefetchedExplorerMetadata = React143.useMemo(() => buildPrefetchedExplorerMetadata(
43950
+ activeFilter,
43951
+ categoryMetadataCategoryId,
43952
+ categoryMetadata
43953
+ ), [activeFilter, categoryMetadata, categoryMetadataCategoryId]);
43936
43954
  const classificationClipIds = React143.useMemo(() => {
43937
43955
  if (!idleTimeVlmEnabled) {
43938
43956
  return [];
package/dist/index.mjs CHANGED
@@ -37418,6 +37418,14 @@ var formatTimestampRange = (startTime, endTime, timezone) => {
37418
37418
  });
37419
37419
  return `${startFormatted} - ${endFormatted}`;
37420
37420
  };
37421
+ var buildPrefetchedExplorerMetadata = (activeFilter, metadataCategoryId, categoryMetadata) => {
37422
+ if (!activeFilter || !metadataCategoryId || metadataCategoryId !== activeFilter || categoryMetadata.length === 0) {
37423
+ return void 0;
37424
+ }
37425
+ return {
37426
+ [activeFilter]: categoryMetadata
37427
+ };
37428
+ };
37421
37429
  var getSecondsBetweenTimestamps = (startTime, endTime) => {
37422
37430
  const startDate = parseTimestamp(startTime);
37423
37431
  const endDate = parseTimestamp(endTime);
@@ -42615,6 +42623,7 @@ var BottlenecksContent = ({
42615
42623
  const [error, setError] = useState(null);
42616
42624
  const [clipClassifications, setClipClassifications] = useState({});
42617
42625
  const [categoryMetadata, setCategoryMetadata] = useState([]);
42626
+ const [categoryMetadataCategoryId, setCategoryMetadataCategoryId] = useState(null);
42618
42627
  const [currentMetadataIndex, setCurrentMetadataIndex] = useState(0);
42619
42628
  const [metadataCache, setMetadataCache] = useState({});
42620
42629
  const invalidateMetadataCache = useCallback((categories) => {
@@ -43086,6 +43095,15 @@ var BottlenecksContent = ({
43086
43095
  const getMetadataCacheKey = useCallback((categoryId) => {
43087
43096
  return `${categoryId}-${effectiveDateString}-${effectiveShiftId}-${snapshotDateTime ?? "nosnap"}-${snapshotClipId ?? "nosnap"}`;
43088
43097
  }, [effectiveDateString, effectiveShiftId, snapshotDateTime, snapshotClipId]);
43098
+ const setVisibleCategoryMetadata = useCallback((categoryId, clips) => {
43099
+ if (activeFilterRef.current !== categoryId) {
43100
+ return false;
43101
+ }
43102
+ categoryMetadataRef.current = clips;
43103
+ setCategoryMetadata(clips);
43104
+ setCategoryMetadataCategoryId(clips.length > 0 ? categoryId : null);
43105
+ return true;
43106
+ }, []);
43089
43107
  const applyMetadataSnapshot = useCallback((categoryId, clips, total) => {
43090
43108
  if (!clips || clips.length === 0) {
43091
43109
  return;
@@ -43095,13 +43113,12 @@ var BottlenecksContent = ({
43095
43113
  ...prev,
43096
43114
  [cacheKey]: clips
43097
43115
  }));
43098
- categoryMetadataRef.current = clips;
43099
- setCategoryMetadata(clips);
43116
+ setVisibleCategoryMetadata(categoryId, clips);
43100
43117
  if (!isPercentileCategory(categoryId) && typeof total === "number") {
43101
43118
  currentTotalRef.current = total;
43102
43119
  setCurrentTotal(total);
43103
43120
  }
43104
- }, [getMetadataCacheKey, isPercentileCategory]);
43121
+ }, [getMetadataCacheKey, isPercentileCategory, setVisibleCategoryMetadata]);
43105
43122
  const getClipTypesForPercentileCategory = useCallback((categoryId) => {
43106
43123
  switch (categoryId) {
43107
43124
  case "fast-cycles":
@@ -43126,6 +43143,7 @@ var BottlenecksContent = ({
43126
43143
  return;
43127
43144
  }
43128
43145
  setCategoryMetadata([]);
43146
+ setCategoryMetadataCategoryId(null);
43129
43147
  categoryMetadataRef.current = [];
43130
43148
  updateActiveFilter(fallbackFilter);
43131
43149
  }, [isFastSlowClipFiltersEnabled, activeFilter, dynamicCounts, clipTypes, updateActiveFilter]);
@@ -43172,6 +43190,7 @@ var BottlenecksContent = ({
43172
43190
  }
43173
43191
  if (!isFastSlowClipFiltersEnabled && (categoryId === "fast-cycles" || categoryId === "slow-cycles")) {
43174
43192
  setCategoryMetadata([]);
43193
+ setCategoryMetadataCategoryId(null);
43175
43194
  categoryMetadataRef.current = [];
43176
43195
  return;
43177
43196
  }
@@ -43185,8 +43204,7 @@ var BottlenecksContent = ({
43185
43204
  try {
43186
43205
  if (cachedMetadata) {
43187
43206
  console.log(`[BottlenecksContent] Using cached metadata for ${categoryId}`);
43188
- setCategoryMetadata(cachedMetadata);
43189
- categoryMetadataRef.current = cachedMetadata;
43207
+ setVisibleCategoryMetadata(categoryId, cachedMetadata);
43190
43208
  if (autoLoadFirstVideo && cachedMetadata.length > 0 && s3ClipsService) {
43191
43209
  const firstClipMeta = cachedMetadata[0];
43192
43210
  try {
@@ -43300,8 +43318,7 @@ var BottlenecksContent = ({
43300
43318
  ...prev,
43301
43319
  [cacheKey]: metadataClips
43302
43320
  }));
43303
- setCategoryMetadata(metadataClips);
43304
- categoryMetadataRef.current = metadataClips;
43321
+ setVisibleCategoryMetadata(categoryId, metadataClips);
43305
43322
  console.log(`[BottlenecksContent] Loaded metadata for ${categoryId}: ${metadataClips.length} clips`);
43306
43323
  if (autoLoadFirstVideo && metadataClips.length > 0 && s3ClipsService) {
43307
43324
  const firstClipMeta = metadataClips[0];
@@ -43320,15 +43337,18 @@ var BottlenecksContent = ({
43320
43337
  }
43321
43338
  }
43322
43339
  } else {
43323
- setCategoryMetadata([]);
43324
- categoryMetadataRef.current = [];
43340
+ if (activeFilterRef.current === categoryId) {
43341
+ setCategoryMetadata([]);
43342
+ setCategoryMetadataCategoryId(null);
43343
+ categoryMetadataRef.current = [];
43344
+ }
43325
43345
  }
43326
43346
  } catch (error2) {
43327
43347
  console.error(`[BottlenecksContent] Error loading category metadata:`, error2);
43328
43348
  } finally {
43329
43349
  setIsCategoryLoading(false);
43330
43350
  }
43331
- }, [workspaceId, effectiveDateString, effectiveShiftId, getMetadataCacheKey, isPercentileCategory, isFastSlowClipFiltersEnabled, metadataCache, s3ClipsService, clearLoadingState, isEffectiveShiftReady, snapshotDateTime, snapshotClipId, supabase]);
43351
+ }, [workspaceId, effectiveDateString, effectiveShiftId, getMetadataCacheKey, isPercentileCategory, isFastSlowClipFiltersEnabled, metadataCache, s3ClipsService, clearLoadingState, isEffectiveShiftReady, snapshotDateTime, snapshotClipId, supabase, setVisibleCategoryMetadata]);
43332
43352
  useEffect(() => {
43333
43353
  if (previousFilterRef.current !== activeFilter) {
43334
43354
  console.log(`Filter changed from ${previousFilterRef.current} to ${activeFilter} - resetting to first video`);
@@ -43338,6 +43358,7 @@ var BottlenecksContent = ({
43338
43358
  setIsNavigating(false);
43339
43359
  loadingCategoryRef.current = null;
43340
43360
  setCategoryMetadata([]);
43361
+ setCategoryMetadataCategoryId(null);
43341
43362
  setCurrentMetadataIndex(0);
43342
43363
  categoryMetadataRef.current = [];
43343
43364
  currentMetadataIndexRef.current = 0;
@@ -43896,14 +43917,11 @@ var BottlenecksContent = ({
43896
43917
  }
43897
43918
  return currentPosition;
43898
43919
  }, [activeFilter, categoryMetadata.length, currentMetadataIndex, currentPosition, isPercentileCategory]);
43899
- const prefetchedExplorerMetadata = useMemo(() => {
43900
- if (!activeFilter || categoryMetadata.length === 0) {
43901
- return void 0;
43902
- }
43903
- return {
43904
- [activeFilter]: categoryMetadata
43905
- };
43906
- }, [activeFilter, categoryMetadata]);
43920
+ const prefetchedExplorerMetadata = useMemo(() => buildPrefetchedExplorerMetadata(
43921
+ activeFilter,
43922
+ categoryMetadataCategoryId,
43923
+ categoryMetadata
43924
+ ), [activeFilter, categoryMetadata, categoryMetadataCategoryId]);
43907
43925
  const classificationClipIds = useMemo(() => {
43908
43926
  if (!idleTimeVlmEnabled) {
43909
43927
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.11.34",
3
+ "version": "6.11.35",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",