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 {
videos: `#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}`,
streams: typeof videoId === 'string' ?
meta_details_videos: `#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}`,
meta_details_streams: typeof videoId === 'string' ?
`#/metadetails/${encodeURIComponent(libItem.type)}/${encodeURIComponent(libItem._id)}/${encodeURIComponent(videoId)}`
:
null,

View file

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

View file

@ -1,22 +1,23 @@
const React = require('react');
const { useServices } = require('stremio/services');
const { useModelState } = require('stremio/common');
const { deepLinking, useModelState } = require('stremio/common');
const mapContinueWatchingPreviewState = (continue_watching_preview) => {
const lib_items = continue_watching_preview.lib_items.map((lib_item) => ({
id: lib_item._id,
type: lib_item.type,
name: lib_item.name,
poster: lib_item.poster,
posterShape: lib_item.posterShape === 'landscape' ? 'square' : lib_item.posterShape,
videoId: lib_item.state.video_id,
progress: lib_item.state.timeOffset > 0 && lib_item.state.duration > 0 ?
lib_item.state.timeOffset / lib_item.state.duration
const lib_items = continue_watching_preview.lib_items.map((libItem) => ({
id: libItem._id,
type: libItem.type,
name: libItem.name,
poster: libItem.poster,
posterShape: libItem.posterShape === 'landscape' ? 'square' : libItem.posterShape,
videoId: libItem.state.video_id,
progress: libItem.state.timeOffset > 0 && libItem.state.duration > 0 ?
libItem.state.timeOffset / libItem.state.duration
:
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 = () => {