mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 22:49:31 +00:00
Refac refresh video list when videoId changing
This commit is contained in:
@@ -45,6 +45,7 @@ const ChannelVideo = ({ videoType }: ChannelVideoProps) => {
|
|||||||
const channel = channelResponse;
|
const channel = channelResponse;
|
||||||
const videoList = videoResponse?.data;
|
const videoList = videoResponse?.data;
|
||||||
const pagination = videoResponse?.paginate;
|
const pagination = videoResponse?.paginate;
|
||||||
|
const refreshWhenVideoIdChanges = videoId !== null;
|
||||||
|
|
||||||
const hasVideos = videoResponse?.data?.length !== 0;
|
const hasVideos = videoResponse?.data?.length !== 0;
|
||||||
|
|
||||||
@@ -80,6 +81,7 @@ const ChannelVideo = ({ videoType }: ChannelVideoProps) => {
|
|||||||
channelId,
|
channelId,
|
||||||
pagination?.current_page,
|
pagination?.current_page,
|
||||||
videoType,
|
videoType,
|
||||||
|
refreshWhenVideoIdChanges,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ const Home = () => {
|
|||||||
const videoList = videoResponse?.data;
|
const videoList = videoResponse?.data;
|
||||||
const pagination = videoResponse?.paginate;
|
const pagination = videoResponse?.paginate;
|
||||||
const continueVideos = continueVideoResponse?.data;
|
const continueVideos = continueVideoResponse?.data;
|
||||||
|
const refreshWhenVideoIdChanges = videoId !== null;
|
||||||
|
|
||||||
const hasVideos = videoResponse?.data?.length !== 0;
|
const hasVideos = videoResponse?.data?.length !== 0;
|
||||||
|
|
||||||
@@ -152,6 +153,7 @@ const Home = () => {
|
|||||||
userConfig.hide_watched,
|
userConfig.hide_watched,
|
||||||
currentPage,
|
currentPage,
|
||||||
pagination?.current_page,
|
pagination?.current_page,
|
||||||
|
refreshWhenVideoIdChanges,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ const Playlist = () => {
|
|||||||
const palylistEntries = playlistResponse?.playlist_entries;
|
const palylistEntries = playlistResponse?.playlist_entries;
|
||||||
const videoArchivedCount = Number(palylistEntries?.filter(video => video.downloaded).length);
|
const videoArchivedCount = Number(palylistEntries?.filter(video => video.downloaded).length);
|
||||||
const videoInPlaylistCount = pagination?.total_hits;
|
const videoInPlaylistCount = pagination?.total_hits;
|
||||||
|
const refreshWhenVideoIdChanges = videoId !== null;
|
||||||
|
|
||||||
const view = userConfig.view_style_home;
|
const view = userConfig.view_style_home;
|
||||||
const gridItems = userConfig.grid_items;
|
const gridItems = userConfig.grid_items;
|
||||||
@@ -86,7 +87,14 @@ const Playlist = () => {
|
|||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
})();
|
})();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [playlistId, userConfig.hide_watched, refresh, currentPage, pagination?.current_page]);
|
}, [
|
||||||
|
playlistId,
|
||||||
|
userConfig.hide_watched,
|
||||||
|
refresh,
|
||||||
|
currentPage,
|
||||||
|
pagination?.current_page,
|
||||||
|
refreshWhenVideoIdChanges,
|
||||||
|
]);
|
||||||
|
|
||||||
if (!playlistId || !playlist) {
|
if (!playlistId || !playlist) {
|
||||||
return `Playlist ${playlistId} not found!`;
|
return `Playlist ${playlistId} not found!`;
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ const Search = () => {
|
|||||||
const playlistList = searchResults?.results.playlist_results;
|
const playlistList = searchResults?.results.playlist_results;
|
||||||
const fulltextList = searchResults?.results.fulltext_results;
|
const fulltextList = searchResults?.results.fulltext_results;
|
||||||
const queryType = searchResults?.queryType;
|
const queryType = searchResults?.queryType;
|
||||||
|
const refreshWhenVideoIdChanges = videoId !== null;
|
||||||
|
|
||||||
const hasSearchQuery = searchTerm.length > 0;
|
const hasSearchQuery = searchTerm.length > 0;
|
||||||
const hasVideos = Number(videoList?.length) > 0;
|
const hasVideos = Number(videoList?.length) > 0;
|
||||||
@@ -89,7 +90,7 @@ const Search = () => {
|
|||||||
} else {
|
} else {
|
||||||
setSearchResults(EmptySearchResponse);
|
setSearchResults(EmptySearchResponse);
|
||||||
}
|
}
|
||||||
}, [debouncedSearchTerm, refresh]);
|
}, [debouncedSearchTerm, refresh, refreshWhenVideoIdChanges]);
|
||||||
|
|
||||||
const fetchResults = async (searchQuery: string) => {
|
const fetchResults = async (searchQuery: string) => {
|
||||||
const searchResults = await loadSearch(searchQuery);
|
const searchResults = await loadSearch(searchQuery);
|
||||||
|
|||||||
Reference in New Issue
Block a user