mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2025-03-25 15:10:12 +00:00
fix linter
This commit is contained in:
parent
8ca943ca7b
commit
09ef342de7
@ -3,7 +3,11 @@ import getApiUrl from '../../configuration/getApiUrl';
|
||||
import getFetchCredentials from '../../configuration/getFetchCredentials';
|
||||
import getCookie from '../../functions/getCookie';
|
||||
|
||||
const updateChannelOverwrites = async (channelId: string, configKey: string, configValue: any) => {
|
||||
const updateChannelOverwrites = async (
|
||||
channelId: string,
|
||||
configKey: string,
|
||||
configValue: string | boolean | number | null,
|
||||
) => {
|
||||
const apiUrl = getApiUrl();
|
||||
const csrfCookie = getCookie('csrftoken');
|
||||
|
||||
|
@ -28,7 +28,7 @@ const loadApiToken = async (): Promise<ApiTokenResponse> => {
|
||||
}
|
||||
|
||||
return apiToken;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return { token: '' };
|
||||
}
|
||||
};
|
||||
|
@ -5,10 +5,10 @@ import iconExit from '/img/icon-exit.svg';
|
||||
import Routes from '../configuration/routes/RouteList';
|
||||
import NavigationItem from './NavigationItem';
|
||||
import logOut from '../api/actions/logOut';
|
||||
import loadIsAdmin from '../functions/getIsAdmin';
|
||||
import useIsAdmin from '../functions/useIsAdmin';
|
||||
|
||||
const Navigation = () => {
|
||||
const isAdmin = loadIsAdmin();
|
||||
const isAdmin = useIsAdmin();
|
||||
const navigate = useNavigate();
|
||||
const handleLogout = async (event: { preventDefault: () => void }) => {
|
||||
event.preventDefault();
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import Routes from '../configuration/routes/RouteList';
|
||||
import loadIsAdmin from '../functions/getIsAdmin';
|
||||
import useIsAdmin from '../functions/useIsAdmin';
|
||||
|
||||
const SettingsNavigation = () => {
|
||||
const isAdmin = loadIsAdmin();
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -7,7 +7,7 @@ export const ColourConstant = {
|
||||
Midnight: 'midnight.css',
|
||||
};
|
||||
|
||||
const importColours = () => {
|
||||
const useColours = () => {
|
||||
const { userConfig } = useUserConfigStore();
|
||||
const stylesheet = userConfig?.config.stylesheet;
|
||||
|
||||
@ -29,4 +29,4 @@ const importColours = () => {
|
||||
}
|
||||
};
|
||||
|
||||
export default importColours;
|
||||
export default useColours;
|
@ -1,10 +1,10 @@
|
||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||
|
||||
const loadIsAdmin = () => {
|
||||
const useIsAdmin = () => {
|
||||
const { userConfig } = useUserConfigStore();
|
||||
const isAdmin = userConfig?.is_staff || userConfig?.is_superuser;
|
||||
|
||||
return isAdmin;
|
||||
};
|
||||
|
||||
export default loadIsAdmin;
|
||||
export default useIsAdmin;
|
@ -1,6 +1,6 @@
|
||||
import { Outlet, useLoaderData, useLocation, useSearchParams } from 'react-router-dom';
|
||||
import Footer from '../components/Footer';
|
||||
import importColours from '../configuration/colours/getColours';
|
||||
import useColours from '../configuration/colours/useColours';
|
||||
import { UserMeType } from '../api/actions/updateUserConfig';
|
||||
import { useEffect, useState } from 'react';
|
||||
import Navigation from '../components/Navigation';
|
||||
@ -46,6 +46,7 @@ const Base = () => {
|
||||
useEffect(() => {
|
||||
setAuth(auth);
|
||||
setUserConfig(userConfig);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@ -79,7 +80,7 @@ const Base = () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [currentPage]);
|
||||
|
||||
importColours();
|
||||
useColours();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -12,7 +12,7 @@ import PaginationDummy from '../components/PaginationDummy';
|
||||
import FormattedNumber from '../components/FormattedNumber';
|
||||
import Button from '../components/Button';
|
||||
import updateChannelOverwrites from '../api/actions/updateChannelOverwrite';
|
||||
import loadIsAdmin from '../functions/getIsAdmin';
|
||||
import useIsAdmin from '../functions/useIsAdmin';
|
||||
|
||||
export type ChannelBaseOutletContextType = {
|
||||
currentPage: number;
|
||||
@ -34,7 +34,7 @@ const ChannelAbout = () => {
|
||||
const { channelId } = useParams() as ChannelAboutParams;
|
||||
const { setStartNotification } = useOutletContext() as ChannelBaseOutletContextType;
|
||||
const navigate = useNavigate();
|
||||
const isAdmin = loadIsAdmin();
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||
const [descriptionExpanded, setDescriptionExpanded] = useState(false);
|
||||
@ -76,7 +76,10 @@ const ChannelAbout = () => {
|
||||
})();
|
||||
}, [refresh, channelId]);
|
||||
|
||||
const handleUpdateConfig = async (configKey: string, configValue: any) => {
|
||||
const handleUpdateConfig = async (
|
||||
configKey: string,
|
||||
configValue: string | boolean | number | null,
|
||||
) => {
|
||||
if (!channel) return;
|
||||
await updateChannelOverwrites(channel.channel_id, configKey, configValue);
|
||||
setRefresh(true);
|
||||
|
@ -8,7 +8,7 @@ import { useEffect, useState } from 'react';
|
||||
import ChannelBanner from '../components/ChannelBanner';
|
||||
import loadChannelNav, { ChannelNavResponseType } from '../api/loader/loadChannelNav';
|
||||
import loadChannelById from '../api/loader/loadChannelById';
|
||||
import loadIsAdmin from '../functions/getIsAdmin';
|
||||
import useIsAdmin from '../functions/useIsAdmin';
|
||||
|
||||
type ChannelParams = {
|
||||
channelId: string;
|
||||
@ -22,7 +22,7 @@ export type ChannelResponseType = {
|
||||
const ChannelBase = () => {
|
||||
const { channelId } = useParams() as ChannelParams;
|
||||
const { currentPage, setCurrentPage } = useOutletContext() as OutletContextType;
|
||||
const isAdmin = loadIsAdmin();
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
const [channelResponse, setChannelResponse] = useState<ChannelResponseType>();
|
||||
const [channelNav, setChannelNav] = useState<ChannelNavResponseType>();
|
||||
|
@ -72,7 +72,6 @@ const ChannelVideo = ({ videoType }: ChannelVideoProps) => {
|
||||
setVideoAggsResponse(channelAggs);
|
||||
setRefresh(false);
|
||||
})();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [
|
||||
refresh,
|
||||
userConfig.config.sort_by,
|
||||
|
@ -12,7 +12,7 @@ import ScrollToTopOnNavigate from '../components/ScrollToTop';
|
||||
import Notifications from '../components/Notifications';
|
||||
import Button from '../components/Button';
|
||||
import updateChannelSubscription from '../api/actions/updateChannelSubscription';
|
||||
import loadIsAdmin from '../functions/getIsAdmin';
|
||||
import useIsAdmin from '../functions/useIsAdmin';
|
||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||
|
||||
type ChannelOverwritesType = {
|
||||
@ -50,7 +50,7 @@ type ChannelsListResponse = {
|
||||
const Channels = () => {
|
||||
const { userConfig, setPartialConfig } = useUserConfigStore();
|
||||
const { currentPage, setCurrentPage } = useOutletContext() as OutletContextType;
|
||||
const isAdmin = loadIsAdmin();
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
const [channelListResponse, setChannelListResponse] = useState<ChannelsListResponse>();
|
||||
const [showAddForm, setShowAddForm] = useState(false);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useRouteError } from 'react-router-dom';
|
||||
import importColours from '../configuration/colours/getColours';
|
||||
import useColours from '../configuration/colours/useColours';
|
||||
|
||||
// This is not always the correct response
|
||||
type ErrorType = {
|
||||
@ -9,7 +9,7 @@ type ErrorType = {
|
||||
|
||||
const ErrorPage = () => {
|
||||
const error = useRouteError() as ErrorType;
|
||||
importColours();
|
||||
useColours();
|
||||
|
||||
console.error('ErrorPage', error);
|
||||
|
||||
|
@ -146,6 +146,7 @@ const Home = () => {
|
||||
setContinueVideoResponse(continueVideoResponse);
|
||||
} catch (error) {
|
||||
console.log('Server error on continue vids?');
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
setVideoReponse(videos);
|
||||
@ -153,7 +154,6 @@ const Home = () => {
|
||||
setRefreshVideoList(false);
|
||||
}
|
||||
})();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [
|
||||
refreshVideoList,
|
||||
userMeConfig.sort_by,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import Routes from '../configuration/routes/RouteList';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import importColours from '../configuration/colours/getColours';
|
||||
import useColours from '../configuration/colours/useColours';
|
||||
import Button from '../components/Button';
|
||||
import signIn from '../api/actions/signIn';
|
||||
|
||||
@ -11,7 +11,7 @@ const Login = () => {
|
||||
const [saveLogin, setSaveLogin] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
importColours();
|
||||
useColours();
|
||||
|
||||
const form_error = false;
|
||||
|
||||
|
@ -22,7 +22,7 @@ import ScrollToTopOnNavigate from '../components/ScrollToTop';
|
||||
import EmbeddableVideoPlayer from '../components/EmbeddableVideoPlayer';
|
||||
import Button from '../components/Button';
|
||||
import loadVideoListByFilter from '../api/loader/loadVideoListByPage';
|
||||
import loadIsAdmin from '../functions/getIsAdmin';
|
||||
import useIsAdmin from '../functions/useIsAdmin';
|
||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||
|
||||
export type PlaylistType = {
|
||||
@ -60,7 +60,7 @@ const Playlist = () => {
|
||||
|
||||
const { userConfig } = useUserConfigStore();
|
||||
const { currentPage, setCurrentPage } = useOutletContext() as OutletContextType;
|
||||
const isAdmin = loadIsAdmin();
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
const userMeConfig = userConfig.config;
|
||||
|
||||
|
@ -15,7 +15,7 @@ import updatePlaylistSubscription from '../api/actions/updatePlaylistSubscriptio
|
||||
import createCustomPlaylist from '../api/actions/createCustomPlaylist';
|
||||
import ScrollToTopOnNavigate from '../components/ScrollToTop';
|
||||
import Button from '../components/Button';
|
||||
import loadIsAdmin from '../functions/getIsAdmin';
|
||||
import useIsAdmin from '../functions/useIsAdmin';
|
||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||
|
||||
export type PlaylistEntryType = {
|
||||
@ -35,7 +35,7 @@ export type PlaylistsResponseType = {
|
||||
const Playlists = () => {
|
||||
const { userConfig, setPartialConfig } = useUserConfigStore();
|
||||
const { currentPage, setCurrentPage } = useOutletContext() as OutletContextType;
|
||||
const isAdmin = loadIsAdmin();
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
const [showAddForm, setShowAddForm] = useState(false);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { ColourVariants } from '../api/actions/updateUserConfig';
|
||||
import { ColourConstant } from '../configuration/colours/getColours';
|
||||
import { ColourConstant } from '../configuration/colours/useColours';
|
||||
import SettingsNavigation from '../components/SettingsNavigation';
|
||||
import Notifications from '../components/Notifications';
|
||||
import Button from '../components/Button';
|
||||
import loadIsAdmin from '../functions/getIsAdmin';
|
||||
import useIsAdmin from '../functions/useIsAdmin';
|
||||
import { useUserConfigStore } from '../stores/UserConfigStore';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
const SettingsUser = () => {
|
||||
const { userConfig, setPartialConfig } = useUserConfigStore();
|
||||
const isAdmin = loadIsAdmin();
|
||||
const isAdmin = useIsAdmin();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [styleSheet, setStyleSheet] = useState<ColourVariants>(userConfig.config.stylesheet);
|
||||
|
@ -37,7 +37,7 @@ import CommentBox, { CommentsType } from '../components/CommentBox';
|
||||
import Button from '../components/Button';
|
||||
import getApiUrl from '../configuration/getApiUrl';
|
||||
import loadVideoNav, { VideoNavResponseType } from '../api/loader/loadVideoNav';
|
||||
import loadIsAdmin from '../functions/getIsAdmin';
|
||||
import useIsAdmin from '../functions/useIsAdmin';
|
||||
|
||||
const isInPlaylist = (videoId: string, playlist: PlaylistType) => {
|
||||
return playlist.playlist_entries.some(entry => {
|
||||
@ -118,7 +118,7 @@ export type VideoCommentsResponseType = {
|
||||
const Video = () => {
|
||||
const { videoId } = useParams() as VideoParams;
|
||||
const navigate = useNavigate();
|
||||
const isAdmin = loadIsAdmin();
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [videoEnded, setVideoEnded] = useState(false);
|
||||
@ -188,6 +188,7 @@ const Video = () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [videoEnded, playlistAutoplay]);
|
||||
|
||||
if (videoResponse === undefined) {
|
||||
|
Loading…
Reference in New Issue
Block a user