diff --git a/src/hooks/useFetchVideos.tsx b/src/hooks/useFetchVideos.tsx index 8991a59..8308f4d 100644 --- a/src/hooks/useFetchVideos.tsx +++ b/src/hooks/useFetchVideos.tsx @@ -37,7 +37,7 @@ export const useFetchVideos = () => { const checkAndUpdateVideo = React.useCallback( (video: Video) => { - const existingVideo = hashMapVideos[video.id]; + const existingVideo = hashMapVideos[video.id + "-" + video.user]; if (!existingVideo) { return true; } else if ( diff --git a/src/pages/Home/VideoList.tsx b/src/pages/Home/VideoList.tsx index 90121fb..58381c8 100644 --- a/src/pages/Home/VideoList.tsx +++ b/src/pages/Home/VideoList.tsx @@ -539,7 +539,8 @@ export const VideoList = ({ mode }: VideoListProps) => { {videos.map((video: any, index: number) => { - const existingVideo = hashMapVideos[video?.id]; + const fullId = video ? `${video.id}-${video.user}` : undefined; + const existingVideo = hashMapVideos[fullId]; let hasHash = false; let videoObj = video; if (existingVideo) { diff --git a/src/pages/Home/VideoListComponentLevel.tsx b/src/pages/Home/VideoListComponentLevel.tsx index 93ed103..f84f42d 100644 --- a/src/pages/Home/VideoListComponentLevel.tsx +++ b/src/pages/Home/VideoListComponentLevel.tsx @@ -133,7 +133,7 @@ export const VideoListComponentLevel = ({ mode }: VideoListProps) => { > {videos.map((video: any, index: number) => { - const existingVideo = hashMapVideos[video.id]; + const existingVideo = hashMapVideos[video.id + '-' + video.user]; let hasHash = false; let videoObj = video; if (existingVideo) { diff --git a/src/pages/PlaylistContent/PlaylistContent.tsx b/src/pages/PlaylistContent/PlaylistContent.tsx index b56f259..79ab8dd 100644 --- a/src/pages/PlaylistContent/PlaylistContent.tsx +++ b/src/pages/PlaylistContent/PlaylistContent.tsx @@ -261,7 +261,8 @@ export const PlaylistContent = () => { setPlaylistData(combinedData); if (combinedData?.videos?.length > 0) { const vid = combinedData?.videos[0]; - const existingVideo = hashMapVideos[vid?.identifier]; + const fullId = vid ? `${vid.identifier}-${vid.name}` : undefined; + const existingVideo = hashMapVideos[fullId]; if (existingVideo) { setVideoData(existingVideo); diff --git a/src/pages/VideoContent/VideoContent.tsx b/src/pages/VideoContent/VideoContent.tsx index d5348b8..43fe257 100644 --- a/src/pages/VideoContent/VideoContent.tsx +++ b/src/pages/VideoContent/VideoContent.tsx @@ -280,7 +280,7 @@ export const VideoContent = () => { React.useEffect(() => { if (name && id) { - const existingVideo = hashMapVideos[id]; + const existingVideo = hashMapVideos[id + '-' + name]; if (existingVideo) { setVideoData(existingVideo); diff --git a/src/state/features/videoSlice.ts b/src/state/features/videoSlice.ts index 5bbaead..57340a5 100644 --- a/src/state/features/videoSlice.ts +++ b/src/state/features/videoSlice.ts @@ -113,16 +113,16 @@ export const videoSlice = createSlice({ }, addToHashMap: (state, action) => { const video = action.payload - state.hashMapVideos[video.id] = video + state.hashMapVideos[video.id + '-' + video.user] = video }, addtoHashMapSuperlikes: (state, action) => { const superlike = action.payload state.hashMapSuperlikes[superlike.identifier] = superlike }, updateInHashMap: (state, action) => { - const { id } = action.payload + const { id, user } = action.payload const video = action.payload - state.hashMapVideos[id] = { ...video } + state.hashMapVideos[id + '-' + user] = { ...video } }, removeFromHashMap: (state, action) => { const idToDelete = action.payload @@ -131,7 +131,7 @@ export const videoSlice = createSlice({ addArrayToHashMap: (state, action) => { const videos = action.payload videos.forEach((video: Video) => { - state.hashMapVideos[video.id] = video + state.hashMapVideos[video.id + '-' + video.user] = video }) }, upsertVideos: (state, action) => {