-
+
diff --git a/frontend/js/components/torrents/list/torrentGroup.js b/frontend/js/components/torrents/list/torrentGroup.js
index 8cfe62f..d74b385 100644
--- a/frontend/js/components/torrents/list/torrentGroup.js
+++ b/frontend/js/components/torrents/list/torrentGroup.js
@@ -18,7 +18,14 @@ export const TorrentGroup = ({ torrentKey }) => {
const title = (torrent) => {
switch (torrent.type) {
case "movie":
- return {torrent.video.title};
+ return (
+
+ {torrent.video.title}
+
+ );
case "episode":
return (
+ produce(state, (draft) => {
+ switch (action.type) {
+ case "MOVIE_FETCH_DETAILS_PENDING":
+ draft.loading = true;
+ break;
+
+ case "MOVIE_FETCH_DETAILS_FULFILLED": {
+ draft.movie = formatMovie(action.payload.response.data);
+ draft.loading = false;
+ break;
+ }
+
+ case "MOVIE_GET_DETAILS_PENDING": {
+ let imdbId = action.payload.main.imdbId;
+ if (draft.movie.imdb_id !== imdbId) {
+ break;
+ }
+
+ draft.movie.fetchingDetails = true;
+ break;
+ }
+
+ case "MOVIE_GET_DETAILS_FULFILLED": {
+ let imdbId = action.payload.main.imdbId;
+ if (draft.movie.imdb_id !== imdbId) {
+ break;
+ }
+
+ draft.movie = formatMovie(action.payload.response.data);
+ break;
+ }
+
+ case "MOVIE_SUBTITLES_UPDATE_PENDING": {
+ let imdbId = action.payload.main.imdbId;
+ if (draft.movie.imdb_id !== imdbId) {
+ break;
+ }
+
+ let lang = action.payload.main.lang;
+ draft.movie.fetchingSubtitles.push(lang);
+ if (draft.movie.subtitles.get(lang)) {
+ draft.movie.subtitles.get(lang).searching = true;
+ }
+ break;
+ }
+
+ case "MOVIE_SUBTITLES_UPDATE_FULFILLED": {
+ let imdbId = action.payload.main.imdbId;
+ if (draft.movie.imdb_id !== imdbId) {
+ break;
+ }
+
+ let lang = action.payload.main.lang;
+ let data = action.payload.response.data;
+ draft.movie.fetchingSubtitles = draft.movie.fetchingSubtitles.filter(
+ (l) => l != lang
+ );
+ if (data) {
+ draft.movie.subtitles.set(lang, formatSubtitle(data));
+ }
+ break;
+ }
+
+ default:
+ return draft;
+ }
+ });
diff --git a/frontend/js/reducers/movies.js b/frontend/js/reducers/movies.js
index ca0d811..e5442cb 100644
--- a/frontend/js/reducers/movies.js
+++ b/frontend/js/reducers/movies.js
@@ -1,7 +1,6 @@
import { produce } from "immer";
-import { formatTorrents } from "../utils";
-import { formatSubtitle, formatSubtitles } from "./utils";
+import { formatSubtitle, formatMovie } from "./utils";
const defaultState = {
loading: false,
@@ -11,14 +10,6 @@ const defaultState = {
exploreOptions: {},
};
-const formatMovie = (movie) => {
- movie.fetchingDetails = false;
- movie.fetchingSubtitles = [];
- movie.torrents = formatTorrents(movie);
- movie.subtitles = formatSubtitles(movie.subtitles);
- return movie;
-};
-
const formatMovies = (movies = []) => {
let allMoviesInPolochon = true;
movies.map((movie) => {
@@ -66,10 +57,17 @@ export default (state = defaultState, action) =>
break;
case "MOVIE_GET_DETAILS_PENDING":
+ if (!draft.movies.get(action.payload.main.imdbId)) {
+ break;
+ }
draft.movies.get(action.payload.main.imdbId).fetchingDetails = true;
break;
case "MOVIE_GET_DETAILS_FULFILLED":
+ if (!draft.movies.get(action.payload.main.imdbId)) {
+ break;
+ }
+
draft.movies.set(
action.payload.response.data.imdb_id,
formatMovie(action.payload.response.data)
@@ -92,6 +90,10 @@ export default (state = defaultState, action) =>
case "MOVIE_SUBTITLES_UPDATE_PENDING": {
let imdbId = action.payload.main.imdbId;
let lang = action.payload.main.lang;
+ if (!draft.movies.get(imdbId)) {
+ break;
+ }
+
draft.movies.get(imdbId).fetchingSubtitles.push(lang);
if (draft.movies.get(imdbId).subtitles.get(lang)) {
draft.movies.get(imdbId).subtitles.get(lang).searching = true;
@@ -103,6 +105,10 @@ export default (state = defaultState, action) =>
let imdbId = action.payload.main.imdbId;
let lang = action.payload.main.lang;
let data = action.payload.response.data;
+ if (!draft.movies.get(imdbId)) {
+ break;
+ }
+
draft.movies.get(imdbId).fetchingSubtitles = draft.movies
.get(imdbId)
.fetchingSubtitles.filter((l) => l != lang);
diff --git a/frontend/js/reducers/show.js b/frontend/js/reducers/show.js
index 80b2e95..f12a214 100644
--- a/frontend/js/reducers/show.js
+++ b/frontend/js/reducers/show.js
@@ -1,7 +1,6 @@
import { produce } from "immer";
-import { formatTorrents } from "../utils";
-import { formatSubtitle, formatSubtitles } from "./utils";
+import { formatTorrents, formatSubtitle, formatSubtitles } from "./utils";
const defaultState = {
loading: false,
diff --git a/frontend/js/reducers/utils.js b/frontend/js/reducers/utils.js
index a395628..41fd61c 100644
--- a/frontend/js/reducers/utils.js
+++ b/frontend/js/reducers/utils.js
@@ -20,3 +20,32 @@ export const formatSubtitle = (subtitle) => {
subtitle.searching = false;
return subtitle;
};
+
+export const formatTorrents = (input) => {
+ if (!input.torrents || input.torrents.length == 0) {
+ return undefined;
+ }
+
+ let torrentMap = new Map();
+ input.torrents.forEach((torrent) => {
+ if (!torrent.result || !torrent.result.source) {
+ return;
+ }
+
+ if (!torrentMap.has(torrent.result.source)) {
+ torrentMap.set(torrent.result.source, new Map());
+ }
+
+ torrentMap.get(torrent.result.source).set(torrent.quality, torrent);
+ });
+
+ return torrentMap;
+};
+
+export const formatMovie = (movie) => {
+ movie.fetchingDetails = false;
+ movie.fetchingSubtitles = [];
+ movie.torrents = formatTorrents(movie);
+ movie.subtitles = formatSubtitles(movie.subtitles);
+ return movie;
+};
diff --git a/frontend/js/utils.js b/frontend/js/utils.js
index 9e06768..4a0e132 100644
--- a/frontend/js/utils.js
+++ b/frontend/js/utils.js
@@ -35,26 +35,5 @@ export const prettySize = (fileSizeInBytes) => {
return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
};
-export const formatTorrents = (input) => {
- if (!input.torrents || input.torrents.length == 0) {
- return undefined;
- }
-
- let torrentMap = new Map();
- input.torrents.forEach((torrent) => {
- if (!torrent.result || !torrent.result.source) {
- return;
- }
-
- if (!torrentMap.has(torrent.result.source)) {
- torrentMap.set(torrent.result.source, new Map());
- }
-
- torrentMap.get(torrent.result.source).set(torrent.quality, torrent);
- });
-
- return torrentMap;
-};
-
export const upperCaseFirst = (string) =>
string.charAt(0).toUpperCase() + string.slice(1);