mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-25 07:11:50 +01:00
it actually continues watching now!
This commit is contained in:
parent
b3cd011bfa
commit
2dd3a3f82a
@ -88,6 +88,30 @@ export function MovieView(props) {
|
|||||||
}
|
}
|
||||||
}, [streamData, selectedSeason])
|
}, [streamData, selectedSeason])
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
let cancel = false;
|
||||||
|
|
||||||
|
if (!cancel) {
|
||||||
|
let ls = JSON.parse(localStorage.getItem("video-progress") || "{}")
|
||||||
|
let key = streamData.type === "show" ? `${season}-${episode}` : "full"
|
||||||
|
let time = ls?.[streamData.source]?.[streamData.type]?.[streamData.slug]?.[key]?.currentlyAt;
|
||||||
|
|
||||||
|
if (time) {
|
||||||
|
const element = document.getElementsByClassName('videoElement')[0];
|
||||||
|
|
||||||
|
if (!element) {
|
||||||
|
return () => { cancel = false }
|
||||||
|
}
|
||||||
|
|
||||||
|
element.currentTime = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancel = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const setProgress = (evt) => {
|
const setProgress = (evt) => {
|
||||||
let ls = JSON.parse(localStorage.getItem("video-progress") || "{}")
|
let ls = JSON.parse(localStorage.getItem("video-progress") || "{}")
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Redirect, useRouteMatch, useHistory } from 'react-router-dom';
|
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import { InputBox } from '../components/InputBox';
|
import { Redirect, useHistory, useRouteMatch } from 'react-router-dom';
|
||||||
import { Title } from '../components/Title';
|
import { Arrow } from '../components/Arrow';
|
||||||
import { Card } from '../components/Card';
|
import { Card } from '../components/Card';
|
||||||
import { ErrorBanner } from '../components/ErrorBanner';
|
import { ErrorBanner } from '../components/ErrorBanner';
|
||||||
|
import { InputBox } from '../components/InputBox';
|
||||||
import { MovieRow } from '../components/MovieRow';
|
import { MovieRow } from '../components/MovieRow';
|
||||||
import { Arrow } from '../components/Arrow';
|
|
||||||
import { Progress } from '../components/Progress';
|
import { Progress } from '../components/Progress';
|
||||||
import { findContent, getStreamUrl, getEpisodes } from '../lib/index';
|
import { Title } from '../components/Title';
|
||||||
import { useMovie } from '../hooks/useMovie';
|
|
||||||
import { TypeSelector } from '../components/TypeSelector';
|
import { TypeSelector } from '../components/TypeSelector';
|
||||||
|
import { useMovie } from '../hooks/useMovie';
|
||||||
|
import { findContent, getEpisodes, getStreamUrl } from '../lib/index';
|
||||||
|
|
||||||
import './Search.css';
|
import './Search.css';
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ export function SearchView() {
|
|||||||
|
|
||||||
setContinueWatching(newContinueWatching)
|
setContinueWatching(newContinueWatching)
|
||||||
})
|
})
|
||||||
});
|
}, []);
|
||||||
|
|
||||||
if (!type || (type !== 'movie' && type !== 'show')) {
|
if (!type || (type !== 'movie' && type !== 'show')) {
|
||||||
return <Redirect to="/movie" />
|
return <Redirect to="/movie" />
|
||||||
@ -229,7 +229,14 @@ export function SearchView() {
|
|||||||
{/* Continue watching */}
|
{/* Continue watching */}
|
||||||
{continueWatching.length > 0 && page === 'watching' ? <Card>
|
{continueWatching.length > 0 && page === 'watching' ? <Card>
|
||||||
<Title>Continue watching</Title>
|
<Title>Continue watching</Title>
|
||||||
{continueWatching?.map((v, i) => (
|
{Object.entries(continueWatching.reduce((a, v) => {
|
||||||
|
if (!a[v.source]) a[v.source] = []
|
||||||
|
a[v.source].push(v)
|
||||||
|
return a;
|
||||||
|
}, {})).map(v => (
|
||||||
|
<div key={v[0]}>
|
||||||
|
<p className="source">{v[0]}</p>
|
||||||
|
{v[1].map((v, i) => (
|
||||||
<MovieRow key={i} title={v.data.meta.title} slug={v.data.meta.slug} type={v.type} year={v.data.meta.year} source={v.source} place={v.data.show} percentage={v.percentageDone} onClick={() => {
|
<MovieRow key={i} title={v.data.meta.title} slug={v.data.meta.slug} type={v.type} year={v.data.meta.year} source={v.source} place={v.data.show} percentage={v.percentageDone} onClick={() => {
|
||||||
if (v.type === 'show') {
|
if (v.type === 'show') {
|
||||||
history.push(`${routeMatch.url}/${v.source}/${v.data.meta.title}/${v.slug}/season/${v.data.show.season}/episode/${v.data.show.episode}`)
|
history.push(`${routeMatch.url}/${v.source}/${v.data.meta.title}/${v.slug}/season/${v.data.show.season}/episode/${v.data.show.episode}`)
|
||||||
@ -241,6 +248,8 @@ export function SearchView() {
|
|||||||
getStream(v.data.meta.title, v.data.meta.slug, v.type, v.source, v.data.meta.year)
|
getStream(v.data.meta.title, v.data.meta.slug, v.type, v.source, v.data.meta.year)
|
||||||
}} />
|
}} />
|
||||||
))}
|
))}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</Card> : <React.Fragment></React.Fragment>}
|
</Card> : <React.Fragment></React.Fragment>}
|
||||||
|
|
||||||
<div className="topRightCredits">
|
<div className="topRightCredits">
|
||||||
|
Loading…
Reference in New Issue
Block a user