Skip to content

Commit b99e4f2

Browse files
authored
prevent index out of array bug (#1361)
1 parent 185767a commit b99e4f2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/gallery/src/components/helpers/videoScrollHelper.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ class VideoScrollHelper {
240240

241241
stop(indexInVideoItems) {
242242
if (indexInVideoItems >= 0) {
243+
const currentVideoId = this.videoItems.find(
244+
(item) => item.idx === indexInVideoItems
245+
)?.id;
243246
const newRating =
244-
this.videoRatingMap.get(this.videoItems[indexInVideoItems].id) +
245-
this.currentItemCount;
246-
this.videoRatingMap.set(this.videoItems[indexInVideoItems].id, newRating);
247+
this.videoRatingMap.get(currentVideoId) + this.currentItemCount;
248+
this.videoRatingMap.set(currentVideoId, newRating);
247249
}
248250
this.setPlayingIdx(-1);
249251
this.playing = false;

0 commit comments

Comments
 (0)