Skip to content

Commit

Permalink
fix ui validation
Browse files Browse the repository at this point in the history
  • Loading branch information
skier233 committed Feb 11, 2025
1 parent 1076e48 commit ee9356d
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions ui/v2.5/src/components/ScenePlayer/ScenePlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -699,31 +699,30 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
if (!player) return;

function loadMarkers() {
const player = getPlayer();
if (!player) return;
const loadMarkersAsync = async () => {
const markerData = scene.scene_markers.map((marker) => ({
title: getMarkerTitle(marker),
seconds: marker.seconds,
end_seconds: marker.end_seconds ?? null,
primaryTag: marker.primary_tag,
}));
const markers = player.markers();

const markers = player!.markers();
markers.clearMarkers();

const uniqueTagNames = markerData
.map((marker) => marker.primaryTag.name)
.filter((value, index, self) => self.indexOf(value) === index);

// Wait for colors
await markers.findColors(uniqueTagNames);

const showRangeTags =
!ScreenUtils.isMobile() && (interfaceConfig?.showRangeMarkers ?? true);
!ScreenUtils.isMobile() &&
(interfaceConfig?.showRangeMarkers ?? true);
const timestampMarkers: IMarker[] = [];
const rangeMarkers: IMarker[] = [];

if (!showRangeTags) {
for (const marker of markerData) {
timestampMarkers.push(marker);
Expand All @@ -737,7 +736,7 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
}
}
}

// Add markers in chunks
const CHUNK_SIZE = 10;
for (let i = 0; i < timestampMarkers.length; i += CHUNK_SIZE) {
Expand All @@ -746,12 +745,12 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
chunk.forEach((m) => markers.addDotMarker(m));
});
}

requestAnimationFrame(() => {
markers.addRangeMarkers(rangeMarkers);
});
};

// Call our async function
void loadMarkersAsync();
}
Expand All @@ -767,7 +766,7 @@ export const ScenePlayer: React.FC<IScenePlayerProps> = ({
player.off("loadedmetadata", loadMarkers);
};
}
}, [getPlayer, scene]);
}, [getPlayer, scene, interfaceConfig]);

useEffect(() => {
const player = getPlayer();
Expand Down

0 comments on commit ee9356d

Please sign in to comment.