mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-08 21:49:38 +00:00
Refac move PlaylistType into loader and fix new response type
This commit is contained in:
@@ -1,6 +1,32 @@
|
|||||||
import APIClient from '../../functions/APIClient';
|
import APIClient from '../../functions/APIClient';
|
||||||
|
|
||||||
const loadPlaylistById = async (playlistId: string | undefined) => {
|
export type PlaylistEntryType = {
|
||||||
|
youtube_id: string;
|
||||||
|
title: string;
|
||||||
|
uploader: string;
|
||||||
|
idx: number;
|
||||||
|
downloaded: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PlaylistType = {
|
||||||
|
playlist_active: boolean;
|
||||||
|
playlist_channel: string;
|
||||||
|
playlist_channel_id: string;
|
||||||
|
playlist_description: string;
|
||||||
|
playlist_entries: PlaylistEntryType[];
|
||||||
|
playlist_id: string;
|
||||||
|
playlist_last_refresh: string;
|
||||||
|
playlist_name: string;
|
||||||
|
playlist_subscribed: boolean;
|
||||||
|
playlist_thumbnail: string;
|
||||||
|
playlist_type: string;
|
||||||
|
_index: string;
|
||||||
|
_score: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PlaylistResponseType = PlaylistType;
|
||||||
|
|
||||||
|
const loadPlaylistById = async (playlistId: string | undefined): Promise<PlaylistResponseType> => {
|
||||||
return APIClient(`/api/playlist/${playlistId}/`);
|
return APIClient(`/api/playlist/${playlistId}/`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ const EmbeddableVideoPlayer = ({ videoId }: EmbeddableVideoPlayerProps) => {
|
|||||||
playlistIds.map(async playlistid => {
|
playlistIds.map(async playlistid => {
|
||||||
const playlistResponse = await loadPlaylistById(playlistid);
|
const playlistResponse = await loadPlaylistById(playlistid);
|
||||||
|
|
||||||
return playlistResponse.data;
|
return playlistResponse;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import Routes from '../configuration/routes/RouteList';
|
import Routes from '../configuration/routes/RouteList';
|
||||||
import { PlaylistType } from '../pages/Playlist';
|
|
||||||
import updatePlaylistSubscription from '../api/actions/updatePlaylistSubscription';
|
import updatePlaylistSubscription from '../api/actions/updatePlaylistSubscription';
|
||||||
import formatDate from '../functions/formatDates';
|
import formatDate from '../functions/formatDates';
|
||||||
import Button from './Button';
|
import Button from './Button';
|
||||||
import PlaylistThumbnail from './PlaylistThumbnail';
|
import PlaylistThumbnail from './PlaylistThumbnail';
|
||||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||||
|
import { PlaylistType } from '../api/loader/loadPlaylistById';
|
||||||
|
|
||||||
type PlaylistListProps = {
|
type PlaylistListProps = {
|
||||||
playlistList: PlaylistType[] | undefined;
|
playlistList: PlaylistType[] | undefined;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Link, useNavigate, useOutletContext, useParams, useSearchParams } from 'react-router-dom';
|
import { Link, useNavigate, useOutletContext, useParams, useSearchParams } from 'react-router-dom';
|
||||||
import loadPlaylistById from '../api/loader/loadPlaylistById';
|
import loadPlaylistById, { PlaylistResponseType } from '../api/loader/loadPlaylistById';
|
||||||
import { OutletContextType } from './Base';
|
import { OutletContextType } from './Base';
|
||||||
import { VideoType } from './Home';
|
import { VideoType } from './Home';
|
||||||
import Filterbar from '../components/Filterbar';
|
import Filterbar from '../components/Filterbar';
|
||||||
import { PlaylistEntryType } from './Playlists';
|
|
||||||
import loadChannelById from '../api/loader/loadChannelById';
|
import loadChannelById from '../api/loader/loadChannelById';
|
||||||
import VideoList from '../components/VideoList';
|
import VideoList from '../components/VideoList';
|
||||||
import Pagination, { PaginationType } from '../components/Pagination';
|
import Pagination, { PaginationType } from '../components/Pagination';
|
||||||
@@ -25,24 +24,6 @@ import loadVideoListByFilter from '../api/loader/loadVideoListByPage';
|
|||||||
import useIsAdmin from '../functions/useIsAdmin';
|
import useIsAdmin from '../functions/useIsAdmin';
|
||||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||||
|
|
||||||
export type PlaylistType = {
|
|
||||||
playlist_active: boolean;
|
|
||||||
playlist_channel: string;
|
|
||||||
playlist_channel_id: string;
|
|
||||||
playlist_description: string;
|
|
||||||
playlist_entries: PlaylistEntryType[];
|
|
||||||
playlist_id: string;
|
|
||||||
playlist_last_refresh: string;
|
|
||||||
playlist_name: string;
|
|
||||||
playlist_subscribed: boolean;
|
|
||||||
playlist_thumbnail: string;
|
|
||||||
playlist_type: string;
|
|
||||||
_index: string;
|
|
||||||
_score: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PlaylistResponseType = PlaylistType;
|
|
||||||
|
|
||||||
export type VideoResponseType = {
|
export type VideoResponseType = {
|
||||||
data?: VideoType[];
|
data?: VideoType[];
|
||||||
paginate?: PaginationType;
|
paginate?: PaginationType;
|
||||||
@@ -94,9 +75,9 @@ const Playlist = () => {
|
|||||||
sort: 'downloaded', // downloaded or published? or playlist sort order?
|
sort: 'downloaded', // downloaded or published? or playlist sort order?
|
||||||
});
|
});
|
||||||
|
|
||||||
const isCustomPlaylist = playlist?.data?.playlist_type === 'custom';
|
const isCustomPlaylist = playlist?.playlist_type === 'custom';
|
||||||
if (!isCustomPlaylist) {
|
if (!isCustomPlaylist) {
|
||||||
const channel = await loadChannelById(playlist.data.playlist_channel_id);
|
const channel = await loadChannelById(playlist.playlist_channel_id);
|
||||||
|
|
||||||
setChannelResponse(channel);
|
setChannelResponse(channel);
|
||||||
}
|
}
|
||||||
@@ -294,7 +275,7 @@ const Playlist = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{playlist.playlist_description && (
|
{playlist.playlist_description !== 'False' && (
|
||||||
<div className="description-box">
|
<div className="description-box">
|
||||||
<p
|
<p
|
||||||
id={descriptionExpanded ? 'text-expand-expanded' : 'text-expand'}
|
id={descriptionExpanded ? 'text-expand-expanded' : 'text-expand'}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { OutletContextType } from './Base';
|
|||||||
import loadPlaylistList from '../api/loader/loadPlaylistList';
|
import loadPlaylistList from '../api/loader/loadPlaylistList';
|
||||||
import Pagination, { PaginationType } from '../components/Pagination';
|
import Pagination, { PaginationType } from '../components/Pagination';
|
||||||
import PlaylistList from '../components/PlaylistList';
|
import PlaylistList from '../components/PlaylistList';
|
||||||
import { PlaylistType } from './Playlist';
|
|
||||||
import updateBulkPlaylistSubscriptions from '../api/actions/updateBulkPlaylistSubscriptions';
|
import updateBulkPlaylistSubscriptions from '../api/actions/updateBulkPlaylistSubscriptions';
|
||||||
import createCustomPlaylist from '../api/actions/createCustomPlaylist';
|
import createCustomPlaylist from '../api/actions/createCustomPlaylist';
|
||||||
import ScrollToTopOnNavigate from '../components/ScrollToTop';
|
import ScrollToTopOnNavigate from '../components/ScrollToTop';
|
||||||
@@ -18,14 +17,7 @@ import useIsAdmin from '../functions/useIsAdmin';
|
|||||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||||
import Notifications from '../components/Notifications';
|
import Notifications from '../components/Notifications';
|
||||||
import updateUserConfig, { UserConfigType } from '../api/actions/updateUserConfig';
|
import updateUserConfig, { UserConfigType } from '../api/actions/updateUserConfig';
|
||||||
|
import { PlaylistType } from '../api/loader/loadPlaylistById';
|
||||||
export type PlaylistEntryType = {
|
|
||||||
youtube_id: string;
|
|
||||||
title: string;
|
|
||||||
uploader: string;
|
|
||||||
idx: number;
|
|
||||||
downloaded: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PlaylistsResponseType = {
|
export type PlaylistsResponseType = {
|
||||||
data?: PlaylistType[];
|
data?: PlaylistType[];
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { useSearchParams } from 'react-router-dom';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { VideoType } from './Home';
|
import { VideoType } from './Home';
|
||||||
import loadSearch from '../api/loader/loadSearch';
|
import loadSearch from '../api/loader/loadSearch';
|
||||||
import { PlaylistType } from './Playlist';
|
|
||||||
import { ChannelType } from './Channels';
|
import { ChannelType } from './Channels';
|
||||||
import VideoList from '../components/VideoList';
|
import VideoList from '../components/VideoList';
|
||||||
import ChannelList from '../components/ChannelList';
|
import ChannelList from '../components/ChannelList';
|
||||||
@@ -12,6 +11,7 @@ import { ViewStyles } from '../configuration/constants/ViewStyle';
|
|||||||
import EmbeddableVideoPlayer from '../components/EmbeddableVideoPlayer';
|
import EmbeddableVideoPlayer from '../components/EmbeddableVideoPlayer';
|
||||||
import SearchExampleQueries from '../components/SearchExampleQueries';
|
import SearchExampleQueries from '../components/SearchExampleQueries';
|
||||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||||
|
import { PlaylistType } from '../api/loader/loadPlaylistById';
|
||||||
|
|
||||||
const EmptySearchResponse: SearchResultsType = {
|
const EmptySearchResponse: SearchResultsType = {
|
||||||
results: {
|
results: {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import loadPlaylistList from '../api/loader/loadPlaylistList';
|
|||||||
import { PlaylistsResponseType } from './Playlists';
|
import { PlaylistsResponseType } from './Playlists';
|
||||||
import PaginationDummy from '../components/PaginationDummy';
|
import PaginationDummy from '../components/PaginationDummy';
|
||||||
import updateCustomPlaylist from '../api/actions/updateCustomPlaylist';
|
import updateCustomPlaylist from '../api/actions/updateCustomPlaylist';
|
||||||
import { PlaylistType } from './Playlist';
|
|
||||||
import loadCommentsbyVideoId from '../api/loader/loadCommentsbyVideoId';
|
import loadCommentsbyVideoId from '../api/loader/loadCommentsbyVideoId';
|
||||||
import CommentBox, { CommentsType } from '../components/CommentBox';
|
import CommentBox, { CommentsType } from '../components/CommentBox';
|
||||||
import Button from '../components/Button';
|
import Button from '../components/Button';
|
||||||
@@ -39,6 +38,7 @@ import getApiUrl from '../configuration/getApiUrl';
|
|||||||
import loadVideoNav, { VideoNavResponseType } from '../api/loader/loadVideoNav';
|
import loadVideoNav, { VideoNavResponseType } from '../api/loader/loadVideoNav';
|
||||||
import useIsAdmin from '../functions/useIsAdmin';
|
import useIsAdmin from '../functions/useIsAdmin';
|
||||||
import ToggleConfig from '../components/ToggleConfig';
|
import ToggleConfig from '../components/ToggleConfig';
|
||||||
|
import { PlaylistType } from '../api/loader/loadPlaylistById';
|
||||||
// import { useAppSettingsStore } from '../stores/AppSettingsStore';
|
// import { useAppSettingsStore } from '../stores/AppSettingsStore';
|
||||||
|
|
||||||
const isInPlaylist = (videoId: string, playlist: PlaylistType) => {
|
const isInPlaylist = (videoId: string, playlist: PlaylistType) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user