mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 20:29:36 +00:00
Fix block pagination hotkeys when embeddableVideoPlayer is active
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link, useSearchParams } from 'react-router-dom';
|
||||||
import { Fragment } from 'react/jsx-runtime';
|
import { Fragment } from 'react/jsx-runtime';
|
||||||
import Routes from '../configuration/routes/RouteList';
|
import Routes from '../configuration/routes/RouteList';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect } from 'react';
|
||||||
@@ -23,6 +23,9 @@ interface Props {
|
|||||||
const Pagination = ({ pagination, setPage }: Props) => {
|
const Pagination = ({ pagination, setPage }: Props) => {
|
||||||
const { total_hits, params, prev_pages, current_page, next_pages, last_page, max_hits } =
|
const { total_hits, params, prev_pages, current_page, next_pages, last_page, max_hits } =
|
||||||
pagination;
|
pagination;
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
|
|
||||||
|
const videoId = searchParams.get('videoId');
|
||||||
|
|
||||||
const totalHits = Number(total_hits);
|
const totalHits = Number(total_hits);
|
||||||
const currentPage = Number(current_page);
|
const currentPage = Number(current_page);
|
||||||
@@ -39,7 +42,7 @@ const Pagination = ({ pagination, setPage }: Props) => {
|
|||||||
(event: KeyboardEvent) => {
|
(event: KeyboardEvent) => {
|
||||||
const { code } = event;
|
const { code } = event;
|
||||||
|
|
||||||
if (code === 'ArrowRight') {
|
if (code === 'ArrowRight' && videoId === null) {
|
||||||
if (currentPage === 0 && totalHits > 1) {
|
if (currentPage === 0 && totalHits > 1) {
|
||||||
setPage(2);
|
setPage(2);
|
||||||
return;
|
return;
|
||||||
@@ -52,7 +55,7 @@ const Pagination = ({ pagination, setPage }: Props) => {
|
|||||||
setPage(currentPage + 1);
|
setPage(currentPage + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code === 'ArrowLeft') {
|
if (code === 'ArrowLeft' && videoId === null) {
|
||||||
if (currentPage === 0) {
|
if (currentPage === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -65,7 +68,7 @@ const Pagination = ({ pagination, setPage }: Props) => {
|
|||||||
setPage(currentPage - 1);
|
setPage(currentPage - 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[currentPage, lastPage, setPage, totalHits],
|
[currentPage, lastPage, setPage, totalHits, videoId],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user