From a51732d8008e2bf576f38db740f3629b93f2594b Mon Sep 17 00:00:00 2001 From: Reza Date: Sun, 31 Oct 2021 23:36:52 +0330 Subject: [PATCH] reza achanged video tube --- src/redux/reducers/public.tsx | 8 +++++--- src/router.js | 2 +- src/util/location.js | 2 +- src/views/Course/Lesson/index.tsx | 2 +- src/views/Course/index.tsx | 5 ++--- src/views/VideoTube/LessonPlayList/index.tsx | 17 ++++++++++------- src/views/VideoTube/index.tsx | 1 + 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/redux/reducers/public.tsx b/src/redux/reducers/public.tsx index 3208850..636efd5 100644 --- a/src/redux/reducers/public.tsx +++ b/src/redux/reducers/public.tsx @@ -1,5 +1,7 @@ import { PublicAction } from "../actions-type"; import proxy from "../proxy"; +import location from '../../util/location'; + const initialState = { homeData: [], newProducts: [], @@ -69,13 +71,13 @@ export default function publicApi(state = initialState, action: PublicAction) { error: null, }; case "public/vod/bookSection": - const videoId: any = localStorage.getItem("category")?.split(",")[2]; + const videoId: any = location.getId(); return { ...state, loading: false, bookSection: data, error: null, - selectedVideo: data?.vods?.filter((item: any) => item.name === videoId)[0] + selectedVideo: data.vods?.filter((item: any) => item.id !== videoId)[0] }; case "public/vod/bookCourse": @@ -98,7 +100,7 @@ export default function publicApi(state = initialState, action: PublicAction) { categories: allCats.map((item: any) => data.vods.filter((item1: any) => item1.categoryId === item) ), - selectedVideo: data?.vods[0], + selectedVideo: data.vods.filter((item : any) => item.id !== location.getId())[0], }; case "public/homePage": let itemsLevel; diff --git a/src/router.js b/src/router.js index 89c3c3a..9c5d542 100644 --- a/src/router.js +++ b/src/router.js @@ -47,7 +47,7 @@ function router({ status }) { - + diff --git a/src/util/location.js b/src/util/location.js index eca402f..aa083ce 100644 --- a/src/util/location.js +++ b/src/util/location.js @@ -8,4 +8,4 @@ class location { const _location = new location(); -export default _location; +export default _location; \ No newline at end of file diff --git a/src/views/Course/Lesson/index.tsx b/src/views/Course/Lesson/index.tsx index a862a6f..16605bc 100644 --- a/src/views/Course/Lesson/index.tsx +++ b/src/views/Course/Lesson/index.tsx @@ -111,7 +111,7 @@ function Lesson({
  • {data.type !== "pdf" && duration(data.duration)}
  • - setCategory(lesson[0].categoryId, data.name)}> + setCategory(lesson[0].categoryId, data.name)}>
  • {"مشاهده"}
  • {/*
  • {data.download ? "دانلود" : }
  • */} diff --git a/src/views/Course/index.tsx b/src/views/Course/index.tsx index 9b7114b..ec6df9e 100644 --- a/src/views/Course/index.tsx +++ b/src/views/Course/index.tsx @@ -94,7 +94,7 @@ function Course({ getInfo, info, categories, loading }: any) { checkFreeCat()} > @@ -133,7 +133,7 @@ function Course({ getInfo, info, categories, loading }: any) { checkFreeCat()} > @@ -173,7 +173,6 @@ function Course({ getInfo, info, categories, loading }: any) { export default connect( (state: any) => ({ - lessons: state.book.mockLessons, info: state.publicApi.bookInfo, categories: state.publicApi.categories, loading: state.publicApi.loading, diff --git a/src/views/VideoTube/LessonPlayList/index.tsx b/src/views/VideoTube/LessonPlayList/index.tsx index a4dd900..3628b81 100644 --- a/src/views/VideoTube/LessonPlayList/index.tsx +++ b/src/views/VideoTube/LessonPlayList/index.tsx @@ -2,6 +2,7 @@ import React, { useEffect } from "react"; import "./index.scss"; import { connect } from "react-redux"; import { publicApi } from "../../../redux/actions"; +import { Link } from "react-router-dom"; function LessonPlayList({ category, @@ -16,12 +17,12 @@ function LessonPlayList({ if (localStorage.getItem("scroll-list") && vods) { const list: HTMLElement = document.getElementById("list") as HTMLElement; const listItem: HTMLElement = document.getElementById( - "listItem" + selectedVideo.id + "listItem" + selectedVideo?.id ) as HTMLElement; const elementHeight: any = (listItem as any)?.offsetHeight; const listHeight: any = (list as any).offsetHeight; - const index = vods.findIndex(( - (item: any) => item.name === selectedVideo.name + const index = vods?.findIndex(( + (item: any) => item?.name === selectedVideo?.name )); console.log(index); console.log(listHeight,elementHeight * (Number(index) + 1)); @@ -52,7 +53,8 @@ function LessonPlayList({ {bookId ? ( category.map((video: any, i: any) => ( -
    {video.name} {/*

    {file.text}

    */}
    - + )) ) : ( -
    {category.name} {/*

    {file.text}

    */}
    - + )} } diff --git a/src/views/VideoTube/index.tsx b/src/views/VideoTube/index.tsx index 0bc7d0b..2bbc322 100644 --- a/src/views/VideoTube/index.tsx +++ b/src/views/VideoTube/index.tsx @@ -12,6 +12,7 @@ import "./index.scss"; import listIcon from "../../assets/icons/list.png"; import { connect } from "react-redux"; import scroll from "../../util/scroll.js"; +import location from "../../util/location.js"; import { book, publicApi } from "../../redux/actions"; import Loader from "../../components/Loader";