@@ -23,7 +31,7 @@ export function Navigation(props: NavigationProps) {
{props.children}
diff --git a/src/components/layout/ThinContainer.tsx b/src/components/layout/ThinContainer.tsx
index c1866956..e1672f63 100644
--- a/src/components/layout/ThinContainer.tsx
+++ b/src/components/layout/ThinContainer.tsx
@@ -8,7 +8,9 @@ interface ThinContainerProps {
export function ThinContainer(props: ThinContainerProps) {
return (
{props.children}
diff --git a/src/components/text/Title.tsx b/src/components/text/Title.tsx
index 436a2663..f6771c6f 100644
--- a/src/components/text/Title.tsx
+++ b/src/components/text/Title.tsx
@@ -3,5 +3,9 @@ export interface TitleProps {
}
export function Title(props: TitleProps) {
- return
{props.children}
;
+ return (
+
+ {props.children}
+
+ );
}
diff --git a/src/constants.ts b/src/constants.ts
deleted file mode 100644
index f9ac5da1..00000000
--- a/src/constants.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export const DISCORD_LINK = "https://discord.gg/Jhqt4Xzpfb";
-export const GITHUB_LINK = "https://github.com/JamesHawkinss/movie-web";
-export const APP_VERSION = "2.1.0";
diff --git a/src/index.tsx b/src/index.tsx
index d0a08f46..d6b93ba0 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,11 +1,12 @@
import React, { Suspense } from "react";
import ReactDOM from "react-dom";
import { HashRouter } from "react-router-dom";
-import "./index.css";
import { ErrorBoundary } from "@/components/layout/ErrorBoundary";
-import App from "./App";
-import "./i18n";
-import { conf } from "./config";
+import { conf } from "@/setup/config";
+
+import App from "@/setup/App";
+import "@/setup/i18n";
+import "@/setup/index.css";
// initialize
const key =
diff --git a/src/providers/list/flixhq/index.ts b/src/providers/list/flixhq/index.ts
index 8fe6564d..304f0157 100644
--- a/src/providers/list/flixhq/index.ts
+++ b/src/providers/list/flixhq/index.ts
@@ -7,7 +7,7 @@ import {
MWProviderMediaResult,
} from "@/providers/types";
-import { conf } from "@/config";
+import { conf } from "@/setup/config";
export const flixhqProvider: MWMediaProvider = {
id: "flixhq",
diff --git a/src/providers/list/gdriveplayer/index.ts b/src/providers/list/gdriveplayer/index.ts
index d13d2414..b1ed69d3 100644
--- a/src/providers/list/gdriveplayer/index.ts
+++ b/src/providers/list/gdriveplayer/index.ts
@@ -9,7 +9,7 @@ import {
MWProviderMediaResult,
} from "@/providers/types";
-import { conf } from "@/config";
+import { conf } from "@/setup/config";
const format = {
stringify: (cipher: any) => {
diff --git a/src/providers/list/gomostream/index.ts b/src/providers/list/gomostream/index.ts
index 092645d4..e9d65d88 100644
--- a/src/providers/list/gomostream/index.ts
+++ b/src/providers/list/gomostream/index.ts
@@ -9,7 +9,7 @@ import {
MWProviderMediaResult,
} from "@/providers/types";
-import { conf } from "@/config";
+import { conf } from "@/setup/config";
export const gomostreamScraper: MWMediaProvider = {
id: "gomostream",
diff --git a/src/providers/list/superstream/index.ts b/src/providers/list/superstream/index.ts
index 3dc26e7b..832e141a 100644
--- a/src/providers/list/superstream/index.ts
+++ b/src/providers/list/superstream/index.ts
@@ -4,7 +4,7 @@
import { customAlphabet } from "nanoid";
import toWebVTT from "srt-webvtt";
import CryptoJS from "crypto-js";
-import { conf } from "@/config";
+import { conf } from "@/setup/config";
import {
MWMediaProvider,
MWMediaType,
diff --git a/src/providers/list/theflix/index.ts b/src/providers/list/theflix/index.ts
index cdfe8e66..01ac7092 100644
--- a/src/providers/list/theflix/index.ts
+++ b/src/providers/list/theflix/index.ts
@@ -15,7 +15,7 @@ import {
} from "@/providers/list/theflix/search";
import { getDataFromPortableSearch } from "@/providers/list/theflix/portableToMedia";
-import { conf } from "@/config";
+import { conf } from "@/setup/config";
export const theFlixScraper: MWMediaProvider = {
id: "theflix",
diff --git a/src/providers/list/theflix/portableToMedia.ts b/src/providers/list/theflix/portableToMedia.ts
index 191e828c..4f42dd47 100644
--- a/src/providers/list/theflix/portableToMedia.ts
+++ b/src/providers/list/theflix/portableToMedia.ts
@@ -1,4 +1,4 @@
-import { conf } from "@/config";
+import { conf } from "@/setup/config";
import { MWMediaType, MWPortableMedia } from "@/providers/types";
const getTheFlixUrl = (media: MWPortableMedia, params?: URLSearchParams) => {
diff --git a/src/providers/list/theflix/search.ts b/src/providers/list/theflix/search.ts
index c0dded24..aa575194 100644
--- a/src/providers/list/theflix/search.ts
+++ b/src/providers/list/theflix/search.ts
@@ -1,4 +1,4 @@
-import { conf } from "@/config";
+import { conf } from "@/setup/config";
import { MWMediaType, MWProviderMediaResult, MWQuery } from "@/providers";
const getTheFlixUrl = (type: "tv-shows" | "movies", params: URLSearchParams) =>
diff --git a/src/providers/list/xemovie/index.ts b/src/providers/list/xemovie/index.ts
index 2d14e73b..82df6848 100644
--- a/src/providers/list/xemovie/index.ts
+++ b/src/providers/list/xemovie/index.ts
@@ -8,7 +8,7 @@ import {
MWMediaCaption,
} from "@/providers/types";
-import { conf } from "@/config";
+import { conf } from "@/setup/config";
export const xemovieScraper: MWMediaProvider = {
id: "xemovie",
diff --git a/src/App.tsx b/src/setup/App.tsx
similarity index 88%
rename from src/App.tsx
rename to src/setup/App.tsx
index b427c62e..b23cf7ee 100644
--- a/src/App.tsx
+++ b/src/setup/App.tsx
@@ -2,10 +2,10 @@ import { Redirect, Route, Switch } from "react-router-dom";
import { MWMediaType } from "@/providers";
import { BookmarkContextProvider } from "@/state/bookmark";
import { WatchedContextProvider } from "@/state/watched";
+
import { NotFoundPage } from "@/views/notfound/NotFoundView";
-import "./index.css";
-import { MediaView } from "./views/MediaView";
-import { SearchView } from "./views/SearchView";
+import { MediaView } from "@/views/MediaView";
+import { SearchView } from "@/views/search/SearchView";
function App() {
return (
diff --git a/src/config.ts b/src/setup/config.ts
similarity index 95%
rename from src/config.ts
rename to src/setup/config.ts
index 6e4fb805..951be497 100644
--- a/src/config.ts
+++ b/src/setup/config.ts
@@ -1,4 +1,4 @@
-import { APP_VERSION, GITHUB_LINK, DISCORD_LINK } from "@/constants";
+import { APP_VERSION, GITHUB_LINK, DISCORD_LINK } from "./constants";
interface Config {
APP_VERSION: string;
diff --git a/src/mw_constants.ts b/src/setup/constants.ts
similarity index 100%
rename from src/mw_constants.ts
rename to src/setup/constants.ts
diff --git a/src/i18n.ts b/src/setup/i18n.ts
similarity index 100%
rename from src/i18n.ts
rename to src/setup/i18n.ts
diff --git a/src/index.css b/src/setup/index.css
similarity index 70%
rename from src/index.css
rename to src/setup/index.css
index eadd4e89..efc192db 100644
--- a/src/index.css
+++ b/src/setup/index.css
@@ -4,13 +4,11 @@
html,
body {
- @apply bg-denim-100 text-denim-700 font-open-sans min-h-screen;
+ @apply bg-denim-100 text-denim-700 font-open-sans min-h-screen overflow-x-hidden;
}
#root {
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
+ padding: 0.05px;
min-height: 100vh;
width: 100%;
}
diff --git a/src/utils/cache.ts b/src/utils/cache.ts
index 383a660e..f5c3be3b 100644
--- a/src/utils/cache.ts
+++ b/src/utils/cache.ts
@@ -1,15 +1,15 @@
export class SimpleCache
{
protected readonly INTERVAL_MS = 2 * 60 * 1000; // 2 minutes
- protected _interval: NodeJS.Timer | null = null;
+ protected _interval: ReturnType | null = null;
protected _compare: ((a: Key, b: Key) => boolean) | null = null;
protected _storage: { key: Key; value: Value; expiry: Date }[] = [];
/*
- ** initialize store, will start the interval
- */
+ ** initialize store, will start the interval
+ */
public initialize(): void {
if (this._interval) throw new Error("cache is already initialized");
this._interval = setInterval(() => {
@@ -22,46 +22,48 @@ export class SimpleCache {
}
/*
- ** destroy cache instance, its not safe to use the instance after calling this
- */
+ ** destroy cache instance, its not safe to use the instance after calling this
+ */
public destroy(): void {
- if (this._interval)
- clearInterval(this._interval);
+ if (this._interval) clearInterval(this._interval);
this.clear();
}
-
+
/*
- ** Set compare function, function must return true if A & B are equal
- */
+ ** Set compare function, function must return true if A & B are equal
+ */
public setCompare(compare: (a: Key, b: Key) => boolean): void {
this._compare = compare;
}
/*
- ** check if cache contains the item
- */
+ ** check if cache contains the item
+ */
public has(key: Key): boolean {
return !!this.get(key);
}
-
+
/*
- ** get item from cache
- */
+ ** get item from cache
+ */
public get(key: Key): Value | undefined {
if (!this._compare) throw new Error("Compare function not set");
- const foundValue = this._storage.find(item => this._compare && this._compare(item.key, key));
- if (!foundValue)
- return undefined;
+ const foundValue = this._storage.find(
+ (item) => this._compare && this._compare(item.key, key)
+ );
+ if (!foundValue) return undefined;
return foundValue.value;
}
-
+
/*
- ** set item from cache, if it already exists, it will overwrite
- */
+ ** set item from cache, if it already exists, it will overwrite
+ */
public set(key: Key, value: Value, expirySeconds: number): void {
if (!this._compare) throw new Error("Compare function not set");
- const foundValue = this._storage.find(item => this._compare && this._compare(item.key, key));
- const expiry = new Date((new Date().getTime()) + (expirySeconds * 1000));
+ const foundValue = this._storage.find(
+ (item) => this._compare && this._compare(item.key, key)
+ );
+ const expiry = new Date(new Date().getTime() + expirySeconds * 1000);
// overwrite old value
if (foundValue) {
@@ -76,12 +78,12 @@ export class SimpleCache {
key,
value,
expiry,
- })
+ });
}
/*
- ** remove item from cache
- */
+ ** remove item from cache
+ */
public remove(key: Key): void {
if (!this._compare) throw new Error("Compare function not set");
this._storage.filter((val) => {
@@ -89,10 +91,10 @@ export class SimpleCache {
return true;
});
}
-
+
/*
- ** clear entire cache storage
- */
+ ** clear entire cache storage
+ */
public clear(): void {
this._storage = [];
}
diff --git a/src/utils/storage.ts b/src/utils/storage.ts
index 51befa7a..9e56e651 100644
--- a/src/utils/storage.ts
+++ b/src/utils/storage.ts
@@ -157,19 +157,19 @@ export function versionedStoreBuilder(): any {
version, // version number
update: migrate
? (data: any) => {
- // update function, and increment version
- const newData = migrate(data);
- newData["--version"] = version; // eslint-disable-line no-param-reassign
- return newData;
- }
+ // update function, and increment version
+ const newData = migrate(data);
+ newData["--version"] = version; // eslint-disable-line no-param-reassign
+ return newData;
+ }
: undefined,
init: create
? () => {
- // return an initial object
- const data = create();
- data["--version"] = version;
- return data;
- }
+ // return an initial object
+ const data = create();
+ data["--version"] = version;
+ return data;
+ }
: undefined,
};
return this;
diff --git a/src/views/MediaView.tsx b/src/views/MediaView.tsx
index 1c121cd2..02ea86e0 100644
--- a/src/views/MediaView.tsx
+++ b/src/views/MediaView.tsx
@@ -120,7 +120,7 @@ function LoadingMediaFooter(props: { error?: boolean }) {
{props.error ? (
-
{t('media.invalidUrl')}
+
{t("media.invalidUrl")}
) : (
@@ -200,7 +200,7 @@ export function MediaView() {
: reactHistory.push("/")
}
direction="left"
- linkText={t('media.arrowText')}
+ linkText={t("media.arrowText")}
/>
diff --git a/src/views/SearchView.tsx b/src/views/SearchView.tsx
deleted file mode 100644
index 5d7fa97b..00000000
--- a/src/views/SearchView.tsx
+++ /dev/null
@@ -1,224 +0,0 @@
-import { useEffect, useMemo, useState } from "react";
-import { WatchedMediaCard } from "@/components/media/WatchedMediaCard";
-import { SearchBarInput } from "@/components/SearchBar";
-import { MWMassProviderOutput, MWQuery, SearchProviders } from "@/providers";
-import { ThinContainer } from "@/components/layout/ThinContainer";
-import { SectionHeading } from "@/components/layout/SectionHeading";
-import { Icons } from "@/components/Icon";
-import { Loading } from "@/components/layout/Loading";
-import { Tagline } from "@/components/text/Tagline";
-import { Title } from "@/components/text/Title";
-import { useDebounce } from "@/hooks/useDebounce";
-import { useLoading } from "@/hooks/useLoading";
-import { IconPatch } from "@/components/buttons/IconPatch";
-import { Navigation } from "@/components/layout/Navigation";
-import { useSearchQuery } from "@/hooks/useSearchQuery";
-import { useWatchedContext } from "@/state/watched/context";
-import {
- getIfBookmarkedFromPortable,
- useBookmarkContext,
-} from "@/state/bookmark/context";
-import { useTranslation } from "react-i18next";
-
-function SearchLoading() {
- const { t } = useTranslation();
- return ;
-}
-
-function SearchSuffix(props: {
- fails: number;
- total: number;
- resultsSize: number;
-}) {
- const { t } = useTranslation();
-
- const allFailed: boolean = props.fails === props.total;
- const icon: Icons = allFailed ? Icons.WARNING : Icons.EYE_SLASH;
-
- return (
-
-
-
- {/* standard suffix */}
- {!allFailed ? (
-
- {props.fails > 0 ? (
-
- {t('search.providersFailed', { fails: props.fails, total: props.total })}
-
- ) : null}
- {props.resultsSize > 0 ? (
-
{t('search.allResults')}
- ) : (
-
{t('search.noResults')}
- )}
-
- ) : null}
-
- {/* Error result */}
- {allFailed ? (
-
-
{t('search.allFailed')}
-
- ) : null}
-
- );
-}
-
-function SearchResultsView({
- searchQuery,
- clear,
-}: {
- searchQuery: MWQuery;
- clear: () => void;
-}) {
- const { t } = useTranslation();
-
- const [results, setResults] = useState();
- const [runSearchQuery, loading, error, success] = useLoading(
- (query: MWQuery) => SearchProviders(query)
- );
-
- useEffect(() => {
- async function runSearch(query: MWQuery) {
- const searchResults = await runSearchQuery(query);
- if (!searchResults) return;
- setResults(searchResults);
- }
-
- if (searchQuery.searchQuery !== "") runSearch(searchQuery);
- }, [searchQuery, runSearchQuery]);
-
- return (
-
- {/* results */}
- {success && results?.results.length ? (
- clear()}
- >
- {results.results.map((v) => (
-
- ))}
-
- ) : null}
-
- {/* search suffix */}
- {success && results ? (
-
- ) : null}
-
- {/* error */}
- {error ? : null}
-
- {/* Loading icon */}
- {loading ? : null}
-
- );
-}
-
-function ExtraItems() {
- const { t } = useTranslation();
-
- const { getFilteredBookmarks } = useBookmarkContext();
- const { getFilteredWatched } = useWatchedContext();
-
- const bookmarks = getFilteredBookmarks();
-
- const watchedItems = getFilteredWatched().filter(
- (v) => !getIfBookmarkedFromPortable(bookmarks, v)
- );
-
- if (watchedItems.length === 0 && bookmarks.length === 0) return null;
-
- return (
-
- {bookmarks.length > 0 ? (
-
- {bookmarks.map((v) => (
-
- ))}
-
- ) : null}
- {watchedItems.length > 0 ? (
-
- {watchedItems.map((v) => (
-
- ))}
-
- ) : null}
-
- );
-}
-
-export function SearchView() {
- const { t } = useTranslation();
-
- const [searching, setSearching] = useState(false);
- const [loading, setLoading] = useState(false);
- const [search, setSearch, setSearchUnFocus] = useSearchQuery();
-
- const debouncedSearch = useDebounce(search, 2000);
- useEffect(() => {
- setSearching(search.searchQuery !== "");
- setLoading(search.searchQuery !== "");
- }, [search]);
- useEffect(() => {
- setLoading(false);
- }, [debouncedSearch]);
-
- const resultView = useMemo(() => {
- if (loading) return ;
- if (searching)
- return (
- setSearch({ searchQuery: "" }, true)}
- />
- );
- return ;
- }, [loading, searching, debouncedSearch, setSearch]);
-
- return (
- <>
-
-
- {/* input section */}
-
-
- {t('search.tagline')}
-
{t('search.title')}
-
-
-
-
- {/* results view */}
- {resultView}
-
- >
- );
-}
diff --git a/src/views/notfound/NotFoundView.tsx b/src/views/notfound/NotFoundView.tsx
index c797e281..6ba492ac 100644
--- a/src/views/notfound/NotFoundView.tsx
+++ b/src/views/notfound/NotFoundView.tsx
@@ -26,11 +26,9 @@ export function NotFoundMedia() {
icon={Icons.EYE_SLASH}
className="mb-6 text-xl text-bink-600"
/>
- {t('notFound.media.title')}
-
- {t('notFound.media.description')}
-
-
+ {t("notFound.media.title")}
+ {t("notFound.media.description")}
+
);
}
@@ -44,11 +42,11 @@ export function NotFoundProvider() {
icon={Icons.EYE_SLASH}
className="mb-6 text-xl text-bink-600"
/>
-
- {t('notFound.provider.description')}
+ {t("notFound.provider.description")}