Refresh the video after getting a new video event
This commit is contained in:
parent
851bc2023c
commit
d4cb2e8993
@ -1,8 +1,8 @@
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { setFetchedTorrents } from "../actions/torrents";
|
||||
import { newMovieEvent } from "../actions/movies";
|
||||
import { newEpisodeEvent } from "../actions/shows";
|
||||
import { newMovieEvent, getMovieDetails } from "../actions/movies";
|
||||
import { newEpisodeEvent, getEpisodeDetails } from "../actions/shows";
|
||||
|
||||
export const WsHandler = () => {
|
||||
const dispatch = useDispatch();
|
||||
@ -67,8 +67,16 @@ export const WsHandler = () => {
|
||||
case "newVideo":
|
||||
if (data.message.type === "movie") {
|
||||
dispatch(newMovieEvent(data.message.data));
|
||||
dispatch(getMovieDetails(data.message.data.imdb_id));
|
||||
} else if (data.message.type === "episode") {
|
||||
dispatch(newEpisodeEvent(data.message.data));
|
||||
dispatch(
|
||||
getEpisodeDetails(
|
||||
data.message.data.show_imdb_id,
|
||||
data.message.data.season,
|
||||
data.message.data.episode
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -84,19 +84,30 @@ export default (state = defaultState, action) =>
|
||||
draft.show.tracked_episode = action.payload.episode; // eslint-disable-line camelcase
|
||||
break;
|
||||
|
||||
case "EPISODE_GET_DETAILS_PENDING":
|
||||
draft.show.seasons
|
||||
.get(action.payload.main.season)
|
||||
.get(action.payload.main.episode).fetching = true;
|
||||
case "EPISODE_GET_DETAILS_PENDING": {
|
||||
const imdbId = action.payload.main.imdbId;
|
||||
if (!draft.show || draft.show.imdb_id !== imdbId) {
|
||||
break;
|
||||
}
|
||||
|
||||
const season = action.payload.main.season;
|
||||
const episode = action.payload.main.episode;
|
||||
draft.show.seasons.get(season).get(episode).fetching = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case "EPISODE_GET_DETAILS_FULFILLED": {
|
||||
let episode = action.payload.response.data;
|
||||
if (!episode) {
|
||||
return draft;
|
||||
const imdbId = action.payload.main.imdbId;
|
||||
if (!draft.show || draft.show.imdb_id !== imdbId) {
|
||||
break;
|
||||
}
|
||||
formatEpisode(episode);
|
||||
draft.show.seasons.get(episode.season).set(episode.episode, episode);
|
||||
|
||||
const season = action.payload.main.season;
|
||||
const episode = action.payload.main.episode;
|
||||
|
||||
let data = action.payload.response.data;
|
||||
formatEpisode(data);
|
||||
draft.show.seasons.get(season).set(episode, data);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user