@@ -119,7 +106,7 @@ export default function MediaTab({ username }: { username: string }) {
onLayoutComplete={() => console.log("Layout complete!")}
>
{media.list.map((data: MediaFile, key: number) => {
- let props = { bookmarks, data, type: "media" };
+ let props = { bookmarks, data, origin, type: "media" };
return (
-
+
);
})}
diff --git a/packages/fakeyou.com/src/v2/view/pages/profile/profile_view/tabs/WeightsTab.tsx b/packages/fakeyou.com/src/v2/view/pages/profile/profile_view/tabs/WeightsTab.tsx
index 8f92b15b06..f3b347254e 100644
--- a/packages/fakeyou.com/src/v2/view/pages/profile/profile_view/tabs/WeightsTab.tsx
+++ b/packages/fakeyou.com/src/v2/view/pages/profile/profile_view/tabs/WeightsTab.tsx
@@ -1,4 +1,5 @@
import React, { useRef, useState } from "react";
+import { useLocation } from "react-router-dom";
import MasonryGrid from "components/common/MasonryGrid/MasonryGrid";
import WeightsCards from "components/common/Card/WeightsCards";
import {
@@ -21,6 +22,7 @@ import SkeletonCard from "components/common/Card/SkeletonCard";
// }
export default function WeightsTab({ username }: { username: string }) {
+ const { pathname: origin } = useLocation();
const gridContainerRef = useRef
(null);
const [sd, sdSet] = useState("all");
const [tts, ttsSet] = useState("all");
@@ -41,6 +43,8 @@ export default function WeightsTab({ username }: { username: string }) {
addQueries: { page_size: 24 },
});
+ console.log("💎",origin);
+
const handlePageClick = (selectedItem: { selected: number }) => {
weights.pageChange(selectedItem.selected);
};
@@ -161,6 +165,7 @@ export default function WeightsTab({ username }: { username: string }) {
let props = {
bookmarks,
data,
+ origin,
showCreator: true,
type: "weights",
};
diff --git a/packages/fakeyou.com/src/v2/view/pages/weight/WeightPage.tsx b/packages/fakeyou.com/src/v2/view/pages/weight/WeightPage.tsx
index 67265eef90..11abaee32e 100644
--- a/packages/fakeyou.com/src/v2/view/pages/weight/WeightPage.tsx
+++ b/packages/fakeyou.com/src/v2/view/pages/weight/WeightPage.tsx
@@ -1,5 +1,5 @@
import React, { useState } from "react";
-import { Link, useParams } from "react-router-dom";
+import { Link, useHistory, useParams, useLocation } from "react-router-dom";
import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper";
import { Weight } from "@storyteller/components/src/api/weights/GetWeight";
import Container from "components/common/Container";
@@ -63,14 +63,15 @@ export default function WeightPage({
enqueueTtsJob,
inferenceJobsByCategory,
}: WeightProps) {
+ const { search } = useLocation();
const { weight_token } = useParams<{ weight_token: string }>();
- const {
- data: weight,
- descriptionMD,
- fetchError,
- isLoading,
- title,
- } = useWeightFetch({ token: weight_token });
+ const origin = search ? new URLSearchParams(search).get("origin") : "";
+ const history = useHistory();
+ const { data: weight, descriptionMD, fetchError, isLoading, title, remove } = useWeightFetch({
+ onRemove: () => { history.push(origin || ""); },
+ token: weight_token
+ });
+
const timeUpdated = moment(weight?.updated_at || "").fromNow();
const dateUpdated = moment(weight?.updated_at || "").format("LLL");
const dateCreated = moment(weight?.updated_at || "").format("LLL");
@@ -332,14 +333,6 @@ export default function WeightPage({
setIsDeleteModalOpen(false);
};
- const handleDelete = () => {
- // if (deleteType === "voice") {
- // voices.delete(deleteItem);
- // voices.refresh();
- // } else if (deleteType === "dataset") datasets.delete(deleteItem);
- // datasets.refresh();
- };
-
let audioWeightCoverImage = "/images/avatars/default-pfp.png";
if (weight.maybe_cover_image_public_bucket_path !== null) {
audioWeightCoverImage = bucketConfig.getCdnUrl(
@@ -578,7 +571,7 @@ export default function WeightPage({
handleClose={closeDeleteModal}
title="Delete Weight"
content={`Are you sure you want to delete "${title}"? This action cannot be undone.`}
- onConfirm={handleDelete}
+ onConfirm={remove}
/>
);