diff --git a/src/components/Buttons/DropdownButton.tsx b/src/components/Buttons/DropdownButton.tsx index bcb567bb..0b517a0a 100644 --- a/src/components/Buttons/DropdownButton.tsx +++ b/src/components/Buttons/DropdownButton.tsx @@ -1,4 +1,3 @@ -import { ButtonControlProps, ButtonControl } from "./ButtonControl"; import { Icon, Icons } from "components/Icon"; import React, { MouseEventHandler, @@ -8,6 +7,7 @@ import React, { } from "react"; import { Backdrop, useBackdrop } from "components/layout/Backdrop"; +import { ButtonControlProps, ButtonControl } from "./ButtonControl"; export interface DropdownButtonProps extends ButtonControlProps { icon: Icons; diff --git a/src/components/Buttons/IconButton.tsx b/src/components/Buttons/IconButton.tsx index b786fc09..7ded2203 100644 --- a/src/components/Buttons/IconButton.tsx +++ b/src/components/Buttons/IconButton.tsx @@ -1,5 +1,5 @@ -import { ButtonControlProps, ButtonControl } from "./ButtonControl"; import { Icon, Icons } from "components/Icon"; +import { ButtonControlProps, ButtonControl } from "./ButtonControl"; export interface IconButtonProps extends ButtonControlProps { icon: Icons; diff --git a/src/components/SearchBar.tsx b/src/components/SearchBar.tsx index b779905d..eda3dd9f 100644 --- a/src/components/SearchBar.tsx +++ b/src/components/SearchBar.tsx @@ -1,9 +1,9 @@ +import { useState } from "react"; +import { MWMediaType, MWQuery } from "providers"; import { DropdownButton } from "./buttons/DropdownButton"; import { Icons } from "./Icon"; import { TextInputControl } from "./text-inputs/TextInputControl"; -import { useState } from "react"; -import { MWMediaType, MWQuery } from "providers"; export interface SearchBarProps { buttonText?: string; diff --git a/src/components/Text/ArrowLink.tsx b/src/components/Text/ArrowLink.tsx index f663d966..6e4ebe92 100644 --- a/src/components/Text/ArrowLink.tsx +++ b/src/components/Text/ArrowLink.tsx @@ -43,7 +43,7 @@ export function ArrowLink(props: ArrowLinkProps) { if (isExternal) return {content}; - else if (isInternal) + if (isInternal) return ( {content} ); diff --git a/src/components/Text/Link.tsx b/src/components/Text/Link.tsx index 443ebe98..7505f41c 100644 --- a/src/components/Text/Link.tsx +++ b/src/components/Text/Link.tsx @@ -32,7 +32,7 @@ export function Link(props: LinkProps) { if (isExternal) return {content}; - else if (isInternal) + if (isInternal) return ( {content} ); diff --git a/src/components/layout/Backdrop.tsx b/src/components/layout/Backdrop.tsx index f6f1d479..eed15e7f 100644 --- a/src/components/layout/Backdrop.tsx +++ b/src/components/layout/Backdrop.tsx @@ -63,6 +63,6 @@ export function Backdrop(props: BackdropProps) { }`} {...fadeProps} onClick={(e) => clickEvent(e.nativeEvent)} - > + /> ); } diff --git a/src/components/layout/ErrorBoundary.tsx b/src/components/layout/ErrorBoundary.tsx index d1c5b209..54428c4a 100644 --- a/src/components/layout/ErrorBoundary.tsx +++ b/src/components/layout/ErrorBoundary.tsx @@ -28,7 +28,7 @@ export class ErrorBoundary extends Component<{}, ErrorBoundaryState> { componentDidCatch(error: any, errorInfo: any) { console.error("Render error caught", error, errorInfo); if (error instanceof Error) { - let realError: Error = error as Error; + const realError: Error = error as Error; this.setState((s) => ({ ...s, hasError: true, diff --git a/src/components/layout/Loading.tsx b/src/components/layout/Loading.tsx index 14fab31e..7af05dfe 100644 --- a/src/components/layout/Loading.tsx +++ b/src/components/layout/Loading.tsx @@ -8,10 +8,10 @@ export function Loading(props: LoadingProps) {
-
-
-
-
+
+
+
+
{props.text && props.text.length ? (

{props.text}

diff --git a/src/components/media/MediaCard.tsx b/src/components/media/MediaCard.tsx index 41eb2ff5..18e7d36f 100644 --- a/src/components/media/MediaCard.tsx +++ b/src/components/media/MediaCard.tsx @@ -11,7 +11,7 @@ import { DotList } from "components/text/DotList"; export interface MediaCardProps { media: MWMediaMeta; - watchedPercentage: Number; + watchedPercentage: number; linkable?: boolean; } diff --git a/src/hooks/useFade.ts b/src/hooks/useFade.ts index 4ba9a9ba..e03413fd 100644 --- a/src/hooks/useFade.ts +++ b/src/hooks/useFade.ts @@ -1,7 +1,7 @@ import React, { useEffect, useState } from "react"; import './useFade.css' -export const useFade = (initial: boolean = false): [boolean, React.Dispatch>, any] => { +export const useFade = (initial = false): [boolean, React.Dispatch>, any] => { const [show, setShow] = useState(initial); const [isVisible, setVisible] = useState(show); diff --git a/src/hooks/useLoading.ts b/src/hooks/useLoading.ts index a2bd51e5..8c61600a 100644 --- a/src/hooks/useLoading.ts +++ b/src/hooks/useLoading.ts @@ -6,7 +6,7 @@ export function useLoading Promise>( const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); const [error, setError] = useState(undefined); - let isMounted = useRef(true); + const isMounted = useRef(true); // we want action to be memoized forever const actionMemo = useMemo(() => action, []); // eslint-disable-line react-hooks/exhaustive-deps diff --git a/src/index.tsx b/src/index.tsx index dc8f917a..96812ef1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,8 +2,8 @@ import React from "react"; import ReactDOM from "react-dom"; import { HashRouter } from "react-router-dom"; import "./index.css"; -import App from "./App"; import { ErrorBoundary } from "components/layout/ErrorBoundary"; +import App from "./App"; ReactDOM.render( diff --git a/src/providers/index.ts b/src/providers/index.ts index 8ecfd4b6..902887ee 100644 --- a/src/providers/index.ts +++ b/src/providers/index.ts @@ -5,6 +5,7 @@ import { MWMediaStream, } from "./types"; import contentCache from "./methods/contentCache"; + export * from "./types"; export * from "./methods/helpers"; export * from "./methods/providers"; @@ -30,7 +31,7 @@ export async function convertPortableToMedia( portable: MWPortableMedia ): Promise { // consult cache first - let output = contentCache.get(portable); + const output = contentCache.get(portable); if (output) return output; const provider = getProviderFromId(portable.providerId); diff --git a/src/providers/list/theflix/index.ts b/src/providers/list/theflix/index.ts index 2f9f1049..83de9c77 100644 --- a/src/providers/list/theflix/index.ts +++ b/src/providers/list/theflix/index.ts @@ -39,7 +39,7 @@ export const theFlixScraper: MWMediaProvider = { const searchData = await getDataFromSearch(searchRes, 10); const results: MWProviderMediaResult[] = []; - for (let item of searchData) { + for (const item of searchData) { results.push(turnDataIntoMedia(item)); } diff --git a/src/providers/list/theflix/portableToMedia.ts b/src/providers/list/theflix/portableToMedia.ts index 3d919c41..65cda77d 100644 --- a/src/providers/list/theflix/portableToMedia.ts +++ b/src/providers/list/theflix/portableToMedia.ts @@ -4,7 +4,7 @@ import { MWMediaType, MWPortableMedia } from "providers/types"; const getTheFlixUrl = (media: MWPortableMedia, params?: URLSearchParams) => { if (media.mediaType === MWMediaType.MOVIE) { 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}`; } @@ -29,7 +29,7 @@ export async function getDataFromPortableSearch( if (media.mediaType === MWMediaType.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; } } diff --git a/src/providers/list/theflix/search.ts b/src/providers/list/theflix/search.ts index 1cd46103..e45b3ffa 100644 --- a/src/providers/list/theflix/search.ts +++ b/src/providers/list/theflix/search.ts @@ -16,7 +16,7 @@ export async function searchTheFlix(query: MWQuery): Promise { ).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( new DOMParser() .parseFromString(page, "text/html") @@ -31,13 +31,13 @@ export function getDataFromSearch(page: string, limit: number = 10): any[] { export function turnDataIntoMedia(data: any): MWProviderMediaResult { return { mediaId: - data.id + - "-" + + `${data.id + }-${ data.name .replace(/[^a-z0-9]+|\s+/gim, " ") .trim() .replace(/\s+/g, "-") - .toLowerCase(), + .toLowerCase()}`, title: data.name, year: new Date(data.releaseDate).getFullYear().toString(), }; diff --git a/src/providers/types.ts b/src/providers/types.ts index fb133199..b4773898 100644 --- a/src/providers/types.ts +++ b/src/providers/types.ts @@ -23,7 +23,7 @@ export interface MWMediaMeta extends MWPortableMedia { year: string; } -export interface MWMedia extends MWMediaMeta {} +export type MWMedia = MWMediaMeta export type MWProviderMediaResult = Omit; diff --git a/src/state/bookmark/context.tsx b/src/state/bookmark/context.tsx index b05936b2..49cf2f8b 100644 --- a/src/state/bookmark/context.tsx +++ b/src/state/bookmark/context.tsx @@ -28,7 +28,7 @@ export function BookmarkContextProvider(props: { children: ReactNode }) { function setBookmarked(data: any) { setBookmarkStore((old) => { - let old2 = JSON.parse(JSON.stringify(old)); + const old2 = JSON.parse(JSON.stringify(old)); let newData = data; if (data.constructor === Function) { newData = data(old2); @@ -65,9 +65,7 @@ export function BookmarkContextProvider(props: { children: ReactNode }) { }); }, getFilteredBookmarks() { - return bookmarkStorage.bookmarks.filter((bookmark) => { - return getProviderMetadata(bookmark.providerId)?.enabled; - }); + return bookmarkStorage.bookmarks.filter((bookmark) => getProviderMetadata(bookmark.providerId)?.enabled); }, bookmarkStore: bookmarkStorage, }; @@ -87,14 +85,12 @@ function getBookmarkIndexFromMedia( bookmarks: MWMediaMeta[], media: MWMediaMeta ): number { - const a = bookmarks.findIndex((v) => { - return ( + const a = bookmarks.findIndex((v) => ( v.mediaId === media.mediaId && v.providerId === media.providerId && v.episode === media.episode && v.season === media.season - ); - }); + )); return a; } diff --git a/src/state/watched/context.tsx b/src/state/watched/context.tsx index f802ee69..75f60ea7 100644 --- a/src/state/watched/context.tsx +++ b/src/state/watched/context.tsx @@ -70,9 +70,7 @@ export function WatchedContextProvider(props: { children: ReactNode }) { }); }, getFilteredWatched() { - return watched.items.filter((item) => { - return getProviderMetadata(item.providerId)?.enabled; - }); + return watched.items.filter((item) => getProviderMetadata(item.providerId)?.enabled); }, watched, }; @@ -92,12 +90,10 @@ export function getWatchedFromPortable( items: WatchedStoreItem[], media: MWMediaMeta ): WatchedStoreItem | undefined { - return items.find((v) => { - return ( + return items.find((v) => ( v.mediaId === media.mediaId && v.providerId === media.providerId && v.episode === media.episode && v.season === media.season - ); - }); + )); } diff --git a/src/utils/cache.ts b/src/utils/cache.ts index 2e08f0fa..383a660e 100644 --- a/src/utils/cache.ts +++ b/src/utils/cache.ts @@ -2,7 +2,9 @@ export class SimpleCache { protected readonly INTERVAL_MS = 2 * 60 * 1000; // 2 minutes protected _interval: NodeJS.Timer | null = null; + protected _compare: ((a: Key, b: Key) => boolean) | null = null; + protected _storage: { key: Key; value: Value; expiry: Date }[] = []; /* diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 0ddb0e22..136b8333 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -86,7 +86,7 @@ function buildStoreObject(d: any) { // add a save object to return value data.save = function save(newData: any) { - let dataToStore = newData || data; + const dataToStore = newData || data; localStorage.setItem(store.id, JSON.stringify(dataToStore)); }; @@ -153,7 +153,7 @@ export function versionedStoreBuilder(): any { // register version this._data.versions[version.toString()] = { - version: version, // version number + version, // version number update: migrate ? (data: any) => { // update function, and increment version