mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-11 02:05:09 +01:00
linting fix
This commit is contained in:
parent
bedac626d1
commit
069c5271df
@ -1,4 +1,3 @@
|
|||||||
import { ButtonControlProps, ButtonControl } from "./ButtonControl";
|
|
||||||
import { Icon, Icons } from "components/Icon";
|
import { Icon, Icons } from "components/Icon";
|
||||||
import React, {
|
import React, {
|
||||||
MouseEventHandler,
|
MouseEventHandler,
|
||||||
@ -8,6 +7,7 @@ import React, {
|
|||||||
} from "react";
|
} from "react";
|
||||||
|
|
||||||
import { Backdrop, useBackdrop } from "components/layout/Backdrop";
|
import { Backdrop, useBackdrop } from "components/layout/Backdrop";
|
||||||
|
import { ButtonControlProps, ButtonControl } from "./ButtonControl";
|
||||||
|
|
||||||
export interface DropdownButtonProps extends ButtonControlProps {
|
export interface DropdownButtonProps extends ButtonControlProps {
|
||||||
icon: Icons;
|
icon: Icons;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { ButtonControlProps, ButtonControl } from "./ButtonControl";
|
|
||||||
import { Icon, Icons } from "components/Icon";
|
import { Icon, Icons } from "components/Icon";
|
||||||
|
import { ButtonControlProps, ButtonControl } from "./ButtonControl";
|
||||||
|
|
||||||
export interface IconButtonProps extends ButtonControlProps {
|
export interface IconButtonProps extends ButtonControlProps {
|
||||||
icon: Icons;
|
icon: Icons;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { MWMediaType, MWQuery } from "providers";
|
||||||
import { DropdownButton } from "./buttons/DropdownButton";
|
import { DropdownButton } from "./buttons/DropdownButton";
|
||||||
import { Icons } from "./Icon";
|
import { Icons } from "./Icon";
|
||||||
import { TextInputControl } from "./text-inputs/TextInputControl";
|
import { TextInputControl } from "./text-inputs/TextInputControl";
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
import { MWMediaType, MWQuery } from "providers";
|
|
||||||
|
|
||||||
export interface SearchBarProps {
|
export interface SearchBarProps {
|
||||||
buttonText?: string;
|
buttonText?: string;
|
||||||
|
@ -43,7 +43,7 @@ export function ArrowLink(props: ArrowLinkProps) {
|
|||||||
|
|
||||||
if (isExternal)
|
if (isExternal)
|
||||||
return <a href={(props as IArrowLinkPropsExternal).url}>{content}</a>;
|
return <a href={(props as IArrowLinkPropsExternal).url}>{content}</a>;
|
||||||
else if (isInternal)
|
if (isInternal)
|
||||||
return (
|
return (
|
||||||
<LinkRouter to={(props as IArrowLinkPropsInternal).to}>{content}</LinkRouter>
|
<LinkRouter to={(props as IArrowLinkPropsInternal).to}>{content}</LinkRouter>
|
||||||
);
|
);
|
||||||
|
@ -32,7 +32,7 @@ export function Link(props: LinkProps) {
|
|||||||
|
|
||||||
if (isExternal)
|
if (isExternal)
|
||||||
return <a target={(props as ILinkPropsExternal).newTab ? "_blank" : undefined} rel="noreferrer" href={(props as ILinkPropsExternal).url}>{content}</a>;
|
return <a target={(props as ILinkPropsExternal).newTab ? "_blank" : undefined} rel="noreferrer" href={(props as ILinkPropsExternal).url}>{content}</a>;
|
||||||
else if (isInternal)
|
if (isInternal)
|
||||||
return (
|
return (
|
||||||
<LinkRouter to={(props as ILinkPropsInternal).to}>{content}</LinkRouter>
|
<LinkRouter to={(props as ILinkPropsInternal).to}>{content}</LinkRouter>
|
||||||
);
|
);
|
||||||
|
@ -63,6 +63,6 @@ export function Backdrop(props: BackdropProps) {
|
|||||||
}`}
|
}`}
|
||||||
{...fadeProps}
|
{...fadeProps}
|
||||||
onClick={(e) => clickEvent(e.nativeEvent)}
|
onClick={(e) => clickEvent(e.nativeEvent)}
|
||||||
></div>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ export class ErrorBoundary extends Component<{}, ErrorBoundaryState> {
|
|||||||
componentDidCatch(error: any, errorInfo: any) {
|
componentDidCatch(error: any, errorInfo: any) {
|
||||||
console.error("Render error caught", error, errorInfo);
|
console.error("Render error caught", error, errorInfo);
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
let realError: Error = error as Error;
|
const realError: Error = error as Error;
|
||||||
this.setState((s) => ({
|
this.setState((s) => ({
|
||||||
...s,
|
...s,
|
||||||
hasError: true,
|
hasError: true,
|
||||||
|
@ -8,10 +8,10 @@ export function Loading(props: LoadingProps) {
|
|||||||
<div className={props.className}>
|
<div className={props.className}>
|
||||||
<div className="flex flex-col items-center justify-center">
|
<div className="flex flex-col items-center justify-center">
|
||||||
<div className="flex h-12 items-center justify-center">
|
<div className="flex h-12 items-center justify-center">
|
||||||
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full"></div>
|
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full" />
|
||||||
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:150ms]"></div>
|
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:150ms]" />
|
||||||
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:300ms]"></div>
|
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:300ms]" />
|
||||||
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:450ms]"></div>
|
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:450ms]" />
|
||||||
</div>
|
</div>
|
||||||
{props.text && props.text.length ? (
|
{props.text && props.text.length ? (
|
||||||
<p className="mt-3 max-w-xs text-sm opacity-75">{props.text}</p>
|
<p className="mt-3 max-w-xs text-sm opacity-75">{props.text}</p>
|
||||||
|
@ -11,7 +11,7 @@ import { DotList } from "components/text/DotList";
|
|||||||
|
|
||||||
export interface MediaCardProps {
|
export interface MediaCardProps {
|
||||||
media: MWMediaMeta;
|
media: MWMediaMeta;
|
||||||
watchedPercentage: Number;
|
watchedPercentage: number;
|
||||||
linkable?: boolean;
|
linkable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import './useFade.css'
|
import './useFade.css'
|
||||||
|
|
||||||
export const useFade = (initial: boolean = false): [boolean, React.Dispatch<React.SetStateAction<boolean>>, any] => {
|
export const useFade = (initial = false): [boolean, React.Dispatch<React.SetStateAction<boolean>>, any] => {
|
||||||
const [show, setShow] = useState<boolean>(initial);
|
const [show, setShow] = useState<boolean>(initial);
|
||||||
const [isVisible, setVisible] = useState<boolean>(show);
|
const [isVisible, setVisible] = useState<boolean>(show);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ export function useLoading<T extends (...args: any) => Promise<any>>(
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [success, setSuccess] = useState(false);
|
const [success, setSuccess] = useState(false);
|
||||||
const [error, setError] = useState<any | undefined>(undefined);
|
const [error, setError] = useState<any | undefined>(undefined);
|
||||||
let isMounted = useRef(true);
|
const isMounted = useRef(true);
|
||||||
|
|
||||||
// we want action to be memoized forever
|
// we want action to be memoized forever
|
||||||
const actionMemo = useMemo(() => action, []); // eslint-disable-line react-hooks/exhaustive-deps
|
const actionMemo = useMemo(() => action, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
@ -2,8 +2,8 @@ import React from "react";
|
|||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import { HashRouter } from "react-router-dom";
|
import { HashRouter } from "react-router-dom";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import App from "./App";
|
|
||||||
import { ErrorBoundary } from "components/layout/ErrorBoundary";
|
import { ErrorBoundary } from "components/layout/ErrorBoundary";
|
||||||
|
import App from "./App";
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
|
@ -5,6 +5,7 @@ import {
|
|||||||
MWMediaStream,
|
MWMediaStream,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import contentCache from "./methods/contentCache";
|
import contentCache from "./methods/contentCache";
|
||||||
|
|
||||||
export * from "./types";
|
export * from "./types";
|
||||||
export * from "./methods/helpers";
|
export * from "./methods/helpers";
|
||||||
export * from "./methods/providers";
|
export * from "./methods/providers";
|
||||||
@ -30,7 +31,7 @@ export async function convertPortableToMedia(
|
|||||||
portable: MWPortableMedia
|
portable: MWPortableMedia
|
||||||
): Promise<MWMedia | undefined> {
|
): Promise<MWMedia | undefined> {
|
||||||
// consult cache first
|
// consult cache first
|
||||||
let output = contentCache.get(portable);
|
const output = contentCache.get(portable);
|
||||||
if (output) return output;
|
if (output) return output;
|
||||||
|
|
||||||
const provider = getProviderFromId(portable.providerId);
|
const provider = getProviderFromId(portable.providerId);
|
||||||
|
@ -39,7 +39,7 @@ export const theFlixScraper: MWMediaProvider = {
|
|||||||
const searchData = await getDataFromSearch(searchRes, 10);
|
const searchData = await getDataFromSearch(searchRes, 10);
|
||||||
|
|
||||||
const results: MWProviderMediaResult[] = [];
|
const results: MWProviderMediaResult[] = [];
|
||||||
for (let item of searchData) {
|
for (const item of searchData) {
|
||||||
results.push(turnDataIntoMedia(item));
|
results.push(turnDataIntoMedia(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { MWMediaType, MWPortableMedia } from "providers/types";
|
|||||||
const getTheFlixUrl = (media: MWPortableMedia, params?: URLSearchParams) => {
|
const getTheFlixUrl = (media: MWPortableMedia, params?: URLSearchParams) => {
|
||||||
if (media.mediaType === MWMediaType.MOVIE) {
|
if (media.mediaType === MWMediaType.MOVIE) {
|
||||||
return `https://theflix.to/movie/${media.mediaId}?${params}`;
|
return `https://theflix.to/movie/${media.mediaId}?${params}`;
|
||||||
} else if (media.mediaType === MWMediaType.SERIES) {
|
} if (media.mediaType === MWMediaType.SERIES) {
|
||||||
return `https://theflix.to/tv-show/${media.mediaId}/season-${media.season}/episode-${media.episode}`;
|
return `https://theflix.to/tv-show/${media.mediaId}/season-${media.season}/episode-${media.episode}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ export async function getDataFromPortableSearch(
|
|||||||
|
|
||||||
if (media.mediaType === MWMediaType.MOVIE) {
|
if (media.mediaType === MWMediaType.MOVIE) {
|
||||||
return JSON.parse(node.innerHTML).props.pageProps.movie;
|
return JSON.parse(node.innerHTML).props.pageProps.movie;
|
||||||
} else if (media.mediaType === MWMediaType.SERIES) {
|
} if (media.mediaType === MWMediaType.SERIES) {
|
||||||
return JSON.parse(node.innerHTML).props.pageProps.selectedTv;
|
return JSON.parse(node.innerHTML).props.pageProps.selectedTv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ export async function searchTheFlix(query: MWQuery): Promise<string> {
|
|||||||
).then((d) => d.text());
|
).then((d) => d.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDataFromSearch(page: string, limit: number = 10): any[] {
|
export function getDataFromSearch(page: string, limit = 10): any[] {
|
||||||
const node: Element = Array.from(
|
const node: Element = Array.from(
|
||||||
new DOMParser()
|
new DOMParser()
|
||||||
.parseFromString(page, "text/html")
|
.parseFromString(page, "text/html")
|
||||||
@ -31,13 +31,13 @@ export function getDataFromSearch(page: string, limit: number = 10): any[] {
|
|||||||
export function turnDataIntoMedia(data: any): MWProviderMediaResult {
|
export function turnDataIntoMedia(data: any): MWProviderMediaResult {
|
||||||
return {
|
return {
|
||||||
mediaId:
|
mediaId:
|
||||||
data.id +
|
`${data.id
|
||||||
"-" +
|
}-${
|
||||||
data.name
|
data.name
|
||||||
.replace(/[^a-z0-9]+|\s+/gim, " ")
|
.replace(/[^a-z0-9]+|\s+/gim, " ")
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/\s+/g, "-")
|
.replace(/\s+/g, "-")
|
||||||
.toLowerCase(),
|
.toLowerCase()}`,
|
||||||
title: data.name,
|
title: data.name,
|
||||||
year: new Date(data.releaseDate).getFullYear().toString(),
|
year: new Date(data.releaseDate).getFullYear().toString(),
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@ export interface MWMediaMeta extends MWPortableMedia {
|
|||||||
year: string;
|
year: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MWMedia extends MWMediaMeta {}
|
export type MWMedia = MWMediaMeta
|
||||||
|
|
||||||
export type MWProviderMediaResult = Omit<MWMedia, "mediaType" | "providerId">;
|
export type MWProviderMediaResult = Omit<MWMedia, "mediaType" | "providerId">;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ export function BookmarkContextProvider(props: { children: ReactNode }) {
|
|||||||
|
|
||||||
function setBookmarked(data: any) {
|
function setBookmarked(data: any) {
|
||||||
setBookmarkStore((old) => {
|
setBookmarkStore((old) => {
|
||||||
let old2 = JSON.parse(JSON.stringify(old));
|
const old2 = JSON.parse(JSON.stringify(old));
|
||||||
let newData = data;
|
let newData = data;
|
||||||
if (data.constructor === Function) {
|
if (data.constructor === Function) {
|
||||||
newData = data(old2);
|
newData = data(old2);
|
||||||
@ -65,9 +65,7 @@ export function BookmarkContextProvider(props: { children: ReactNode }) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getFilteredBookmarks() {
|
getFilteredBookmarks() {
|
||||||
return bookmarkStorage.bookmarks.filter((bookmark) => {
|
return bookmarkStorage.bookmarks.filter((bookmark) => getProviderMetadata(bookmark.providerId)?.enabled);
|
||||||
return getProviderMetadata(bookmark.providerId)?.enabled;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
bookmarkStore: bookmarkStorage,
|
bookmarkStore: bookmarkStorage,
|
||||||
};
|
};
|
||||||
@ -87,14 +85,12 @@ function getBookmarkIndexFromMedia(
|
|||||||
bookmarks: MWMediaMeta[],
|
bookmarks: MWMediaMeta[],
|
||||||
media: MWMediaMeta
|
media: MWMediaMeta
|
||||||
): number {
|
): number {
|
||||||
const a = bookmarks.findIndex((v) => {
|
const a = bookmarks.findIndex((v) => (
|
||||||
return (
|
|
||||||
v.mediaId === media.mediaId &&
|
v.mediaId === media.mediaId &&
|
||||||
v.providerId === media.providerId &&
|
v.providerId === media.providerId &&
|
||||||
v.episode === media.episode &&
|
v.episode === media.episode &&
|
||||||
v.season === media.season
|
v.season === media.season
|
||||||
);
|
));
|
||||||
});
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +70,7 @@ export function WatchedContextProvider(props: { children: ReactNode }) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getFilteredWatched() {
|
getFilteredWatched() {
|
||||||
return watched.items.filter((item) => {
|
return watched.items.filter((item) => getProviderMetadata(item.providerId)?.enabled);
|
||||||
return getProviderMetadata(item.providerId)?.enabled;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
watched,
|
watched,
|
||||||
};
|
};
|
||||||
@ -92,12 +90,10 @@ export function getWatchedFromPortable(
|
|||||||
items: WatchedStoreItem[],
|
items: WatchedStoreItem[],
|
||||||
media: MWMediaMeta
|
media: MWMediaMeta
|
||||||
): WatchedStoreItem | undefined {
|
): WatchedStoreItem | undefined {
|
||||||
return items.find((v) => {
|
return items.find((v) => (
|
||||||
return (
|
|
||||||
v.mediaId === media.mediaId &&
|
v.mediaId === media.mediaId &&
|
||||||
v.providerId === media.providerId &&
|
v.providerId === media.providerId &&
|
||||||
v.episode === media.episode &&
|
v.episode === media.episode &&
|
||||||
v.season === media.season
|
v.season === media.season
|
||||||
);
|
));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@ export class SimpleCache<Key, Value> {
|
|||||||
protected readonly INTERVAL_MS = 2 * 60 * 1000; // 2 minutes
|
protected readonly INTERVAL_MS = 2 * 60 * 1000; // 2 minutes
|
||||||
|
|
||||||
protected _interval: NodeJS.Timer | null = null;
|
protected _interval: NodeJS.Timer | null = null;
|
||||||
|
|
||||||
protected _compare: ((a: Key, b: Key) => boolean) | null = null;
|
protected _compare: ((a: Key, b: Key) => boolean) | null = null;
|
||||||
|
|
||||||
protected _storage: { key: Key; value: Value; expiry: Date }[] = [];
|
protected _storage: { key: Key; value: Value; expiry: Date }[] = [];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -86,7 +86,7 @@ function buildStoreObject(d: any) {
|
|||||||
|
|
||||||
// add a save object to return value
|
// add a save object to return value
|
||||||
data.save = function save(newData: any) {
|
data.save = function save(newData: any) {
|
||||||
let dataToStore = newData || data;
|
const dataToStore = newData || data;
|
||||||
localStorage.setItem(store.id, JSON.stringify(dataToStore));
|
localStorage.setItem(store.id, JSON.stringify(dataToStore));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ export function versionedStoreBuilder(): any {
|
|||||||
|
|
||||||
// register version
|
// register version
|
||||||
this._data.versions[version.toString()] = {
|
this._data.versions[version.toString()] = {
|
||||||
version: version, // version number
|
version, // version number
|
||||||
update: migrate
|
update: migrate
|
||||||
? (data: any) => {
|
? (data: any) => {
|
||||||
// update function, and increment version
|
// update function, and increment version
|
||||||
|
Loading…
Reference in New Issue
Block a user