deep linking integrated in continue watching preview

This commit is contained in:
nklhrstv 2020-04-06 10:22:17 +03:00
parent c9076155a2
commit c0dc42484d
3 changed files with 16 additions and 15 deletions

View file

@ -31,8 +31,8 @@ const withLibItem = ({ libItem, streams = {} }) => {
: :
[]; [];
return { return {
videos: `#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}`, meta_details_videos: `#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}`,
streams: typeof videoId === 'string' ? meta_details_streams: typeof videoId === 'string' ?
`#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}/${encodeURIComponent(videoId)}` `#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}/${encodeURIComponent(videoId)}`
: :
null, null,

View file

@ -18,7 +18,7 @@ const Board = () => {
title={'Continue Watching'} title={'Continue Watching'}
items={continueWatchingPreview.lib_items} items={continueWatchingPreview.lib_items}
itemComponent={LibItem} itemComponent={LibItem}
href={'#/continuewatching'} deepLinks={continueWatchingPreview.deepLinks}
/> />
: :
null null

View file

@ -1,22 +1,23 @@
const React = require('react'); const React = require('react');
const { useServices } = require('stremio/services'); const { useServices } = require('stremio/services');
const { useModelState } = require('stremio/common'); const { deepLinking, useModelState } = require('stremio/common');
const mapContinueWatchingPreviewState = (continue_watching_preview) => { const mapContinueWatchingPreviewState = (continue_watching_preview) => {
const lib_items = continue_watching_preview.lib_items.map((lib_item) => ({ const lib_items = continue_watching_preview.lib_items.map((libItem) => ({
id: lib_item._id, id: libItem._id,
type: lib_item.type, type: libItem.type,
name: lib_item.name, name: libItem.name,
poster: lib_item.poster, poster: libItem.poster,
posterShape: lib_item.posterShape === 'landscape' ? 'square' : lib_item.posterShape, posterShape: libItem.posterShape === 'landscape' ? 'square' : libItem.posterShape,
videoId: lib_item.state.video_id, videoId: libItem.state.video_id,
progress: lib_item.state.timeOffset > 0 && lib_item.state.duration > 0 ? progress: libItem.state.timeOffset > 0 && libItem.state.duration > 0 ?
lib_item.state.timeOffset / lib_item.state.duration libItem.state.timeOffset / libItem.state.duration
: :
null, null,
href: `#/metadetails/${encodeURIComponent(lib_item.type)}/${encodeURIComponent(lib_item._id)}${lib_item.state.video_id !== null ? `/${encodeURIComponent(lib_item.state.video_id)}` : ''}` deepLinks: deepLinking.withLibItem({ libItem })
})); }));
return { lib_items }; const deepLinks = { discover: '#/continuewatching' };
return { lib_items, deepLinks };
}; };
const useContinueWatchingPreview = () => { const useContinueWatchingPreview = () => {