diff --git a/packages/fakeyou.com/src/components/common/Searcher/Searcher.scss b/packages/fakeyou.com/src/components/common/Searcher/Searcher.scss
index 10fd7bdd07..cd4a12b071 100644
--- a/packages/fakeyou.com/src/components/common/Searcher/Searcher.scss
+++ b/packages/fakeyou.com/src/components/common/Searcher/Searcher.scss
@@ -2,7 +2,16 @@
.searcher-container {
&.in-modal {
- overflow: hidden;
- max-height: 50vh;
+ overflow-x: hidden;
+ overflow-y: auto;
+ max-height: 65vh;
+ }
+}
+
+@media screen and (max-width: 992px) {
+ .searcher-container {
+ &.in-modal {
+ max-height: 70vh;
+ }
}
}
diff --git a/packages/fakeyou.com/src/components/common/Searcher/Searcher.tsx b/packages/fakeyou.com/src/components/common/Searcher/Searcher.tsx
index f9f8193bd8..e3626d46cf 100644
--- a/packages/fakeyou.com/src/components/common/Searcher/Searcher.tsx
+++ b/packages/fakeyou.com/src/components/common/Searcher/Searcher.tsx
@@ -1,80 +1,127 @@
-import React, { useRef } from "react";
+import React, { useCallback, useRef, useState } from "react";
import Input from "../Input";
import { faSearch } from "@fortawesome/pro-solid-svg-icons";
import MasonryGrid from "../MasonryGrid/MasonryGrid";
-import MediaCards from "../Card/MediaCards";
import "./Searcher.scss";
+import { Weight } from "@storyteller/components/src/api/weights/GetWeight";
+import { useBookmarks, useRatings } from "hooks";
+import { SearchWeights } from "@storyteller/components/src/api/weights/SearchWeights";
+import debounce from "lodash.debounce";
+import WeightsCards from "../Card/WeightsCards";
+import LoadingSpinner from "../LoadingSpinner";
interface SearcherProps {
- data?: any[];
type?: "page" | "modal";
dataType?: "media" | "weights";
+ weightType?: string;
+ onResultSelect?: () => void;
+ weightTypeFilter?: any;
}
export default function Searcher({
- data,
type = "page",
- dataType = "media",
+ dataType = "weights",
+ weightType = "all",
+ onResultSelect,
+ weightTypeFilter,
}: SearcherProps) {
const gridContainerRef = useRef
(null);
+ const [searchTerm, setSearchTerm] = useState("");
+ const [foundWeights, setFoundWeights] = useState([]);
+ const [isSearching, setIsSearching] = useState(false);
+ const [searchCompleted, setSearchCompleted] = useState(0);
+ const bookmarks = useBookmarks();
+ const ratings = useRatings();
+
+ const handleInputChange = (e: any) => {
+ const newValue = e.target.value;
+ setSearchTerm(newValue);
+ debouncedDoSearch(newValue);
+ };
+
+ const doSearch = useCallback(
+ async (value: string) => {
+ let request: any = {
+ search_term: value,
+ };
+
+ setIsSearching(true);
+
+ if (weightType !== "all") {
+ request[weightTypeFilter] = weightType;
+ }
+
+ let response = await SearchWeights(request);
+
+ if (response.success) {
+ let weights = [...response.weights];
+ setFoundWeights(weights);
+ setSearchCompleted(prev => prev + 1);
+ } else {
+ setFoundWeights([]);
+ }
+
+ setIsSearching(false);
+ },
+ [setFoundWeights, weightType, setSearchCompleted, weightTypeFilter]
+ );
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ const debouncedDoSearch = useCallback(
+ debounce(searchTerm => {
+ doSearch(searchTerm);
+ }, 250),
+ [doSearch]
+ );
return (
-
+
{/* Result Cards */}
-
console.log("Layout complete!")}
- >
- {data &&
- dataType === "media" &&
- data.map((data: any, key: number) => {
- let props = {
- data,
- origin,
- type: "media",
- showCreator: true,
- };
+ {isSearching ? (
+
+ ) : (
+ console.log("Layout complete!")}
+ >
+ {dataType === "weights" &&
+ foundWeights.map((data: any, key: number) => {
+ let props = {
+ data,
+ bookmarks,
+ ratings,
+ showCreator: true,
+ type: "weights",
+ inSearcher: true,
+ onResultSelect,
+ };
- return (
-
-
-
- );
- })}
-
- {data &&
- dataType === "weights" &&
- data.map((data: any, key: number) => {
- let props = {
- data,
- origin,
- type: "media",
- showCreator: true,
- };
-
- return (
-
-
-
- );
- })}
-
+ return (
+
+
+
+ );
+ })}
+
+ )}
);
diff --git a/packages/fakeyou.com/src/components/common/SelectSearcher/SelectSearcher.tsx b/packages/fakeyou.com/src/components/common/SelectSearcher/SelectSearcher.tsx
new file mode 100644
index 0000000000..7ab3beec56
--- /dev/null
+++ b/packages/fakeyou.com/src/components/common/SelectSearcher/SelectSearcher.tsx
@@ -0,0 +1,76 @@
+import React, { useState } from "react";
+import Searcher from "../Searcher";
+import Modal from "../Modal";
+import NonRouteTabs from "../Tabs/NonRouteTabs";
+import Input from "../Input";
+import Button from "../Button";
+import useToken from "hooks/useToken";
+
+interface SelectSearcherProps {
+ label?: string;
+ weightTypeFilter?: string;
+}
+
+export default function SelectSearcher({
+ label,
+ weightTypeFilter,
+}: SelectSearcherProps) {
+ const [isModalOpen, setIsModalOpen] = useState(false);
+ const { weightTitle } = useToken();
+
+ const openModal = () => {
+ setIsModalOpen(true);
+ };
+
+ const closeModal = () => {
+ setIsModalOpen(false);
+ };
+
+ const searchTabs = [
+ {
+ label: "All LoRA Weights",
+ content: (
+
+ ),
+ padding: true,
+ },
+ {
+ label: "Bookmarked",
+ content: ,
+ padding: true,
+ },
+ ];
+ return (
+ <>
+
+ {label &&
}
+
+
+
+
+
+
+
+ }
+ showButtons={false}
+ padding={false}
+ large={true}
+ position="top"
+ mobileFullscreen={true}
+ />
+ >
+ );
+}
diff --git a/packages/fakeyou.com/src/hooks/useToken/index.ts b/packages/fakeyou.com/src/hooks/useToken/index.ts
new file mode 100644
index 0000000000..340992423f
--- /dev/null
+++ b/packages/fakeyou.com/src/hooks/useToken/index.ts
@@ -0,0 +1 @@
+export { default } from "./useToken";
diff --git a/packages/fakeyou.com/src/hooks/useToken/useToken.tsx b/packages/fakeyou.com/src/hooks/useToken/useToken.tsx
new file mode 100644
index 0000000000..31eb2940e7
--- /dev/null
+++ b/packages/fakeyou.com/src/hooks/useToken/useToken.tsx
@@ -0,0 +1,17 @@
+import { create } from "zustand";
+
+interface TokenState {
+ token: string | null;
+ setToken: (newToken: string | null) => void;
+ weightTitle?: string | null;
+ setWeightTitle?: (newWeightTitle: string | null) => void;
+}
+
+const useToken = create(set => ({
+ token: null,
+ setToken: newToken => set({ token: newToken }),
+ weightTitle: null,
+ setWeightTitle: newWeightTitle => set({ weightTitle: newWeightTitle }),
+}));
+
+export default useToken;
diff --git a/packages/fakeyou.com/src/v2/view/pages/dev_upload/DevUpload.tsx b/packages/fakeyou.com/src/v2/view/pages/dev_upload/DevUpload.tsx
index ee7197177e..e674ac038d 100644
--- a/packages/fakeyou.com/src/v2/view/pages/dev_upload/DevUpload.tsx
+++ b/packages/fakeyou.com/src/v2/view/pages/dev_upload/DevUpload.tsx
@@ -4,36 +4,40 @@ import PageHeader from "components/layout/PageHeader";
import React, { useState } from "react";
import { Button } from "components/common";
import { faUpload } from "@fortawesome/pro-solid-svg-icons";
-import { UploadMedia, UploadMediaResponse } from "@storyteller/components/src/api/media_files/UploadMedia";
+import {
+ UploadMedia,
+ UploadMediaResponse,
+} from "@storyteller/components/src/api/media_files/UploadMedia";
import { v4 as uuidv4 } from "uuid";
-import { Link } from 'react-router-dom';
+import { Link } from "react-router-dom";
+import SelectSearcher from "components/common/SelectSearcher/SelectSearcher";
interface DevUploadProps {}
export default function DevUpload(props: DevUploadProps) {
const [file, fileSet] = useState(null);
- const [tokens,tokensSet] = useState([]);
+ const [tokens, tokensSet] = useState([]);
const handleFileChange = (event: any) => {
fileSet(event.target.files[0]);
};
-
const handleUpload = () => {
- if (file) UploadMedia({
- uuid_idempotency_token: uuidv4(),
- file,
- source: "file",
- }) // if there an audio file it uploads here
- .then((res: UploadMediaResponse) => {
- if ("media_file_token" in res) {
- console.log("📁 upload response:", res);
- tokensSet([res.media_file_token, ...tokens]);
- fileSet(null);
- }
- });
+ if (file)
+ UploadMedia({
+ uuid_idempotency_token: uuidv4(),
+ file,
+ source: "file",
+ }) // if there an audio file it uploads here
+ .then((res: UploadMediaResponse) => {
+ if ("media_file_token" in res) {
+ console.log("📁 upload response:", res);
+ tokensSet([res.media_file_token, ...tokens]);
+ fileSet(null);
+ }
+ });
else console.log("🥺 no file");
- }
+ };
return (
@@ -59,12 +63,15 @@ export default function DevUpload(props: DevUploadProps) {
/>
- {
- tokens.map((token: string, key: number) =>
-
{ token })
- }
+ {tokens.map((token: string, key: number) => (
+