From cc251c8e2dcb7adbd99a3ffa8b0377fc3cc4d6ac Mon Sep 17 00:00:00 2001 From: nklhrstv Date: Tue, 7 Apr 2020 13:05:42 +0300 Subject: [PATCH] deep links for libitem fixed --- src/common/deepLinking.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/common/deepLinking.js b/src/common/deepLinking.js index 6037cc0f2..efe3a11a1 100644 --- a/src/common/deepLinking.js +++ b/src/common/deepLinking.js @@ -22,15 +22,8 @@ const withMetaItem = ({ metaItem }) => { }; const withLibItem = ({ libItem, streams = {} }) => { - const videoId = typeof libItem.state.video_id === 'string' ? - libItem.state.video_id - : - typeof libItem.behaviorHints.defaultVideoId === 'string' ? - libItem.behaviorHints.defaultVideoId - : - null; - const [stream, streamTransportUrl, metaTransportUrl] = typeof videoId === 'string' && typeof streams[`${encodeURIComponent(libItem._id)}/${encodeURIComponent(videoId)}`] === 'object' ? - streams[`${encodeURIComponent(libItem._id)}/${encodeURIComponent(videoId)}`] + const [stream, streamTransportUrl, metaTransportUrl] = typeof libItem.state.video_id === 'string' && typeof streams[`${encodeURIComponent(libItem._id)}/${encodeURIComponent(libItem.state.video_id)}`] === 'object' ? + streams[`${encodeURIComponent(libItem._id)}/${encodeURIComponent(libItem.state.video_id)}`] : []; return { @@ -38,13 +31,16 @@ const withLibItem = ({ libItem, streams = {} }) => { `#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}` : null, - meta_details_streams: typeof videoId === 'string' ? - `#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}/${encodeURIComponent(videoId)}` + meta_details_streams: typeof libItem.state.video_id === 'string' ? + `#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}/${encodeURIComponent(libItem.state.video_id)}` : - null, + typeof libItem.behaviorHints.defaultVideoId === 'string' ? + `#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}/${encodeURIComponent(libItem.behaviorHints.defaultVideoId)}` + : + null, // TODO check if stream is external - player: typeof videoId === 'string' && typeof stream === 'object' && typeof streamTransportUrl === 'string' && typeof metaTransportUrl === 'string' ? - `#/player/${encodeURIComponent(serializeStream(stream))}/${encodeURIComponent(streamTransportUrl)}/${encodeURIComponent(metaTransportUrl)}/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}/${encodeURIComponent(videoId)}` + player: typeof libItem.state.video_id === 'string' && typeof stream === 'object' && typeof streamTransportUrl === 'string' && typeof metaTransportUrl === 'string' ? + `#/player/${encodeURIComponent(serializeStream(stream))}/${encodeURIComponent(streamTransportUrl)}/${encodeURIComponent(metaTransportUrl)}/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}/${encodeURIComponent(libItem.state.video_id)}` : null };