mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-18 15:44:36 +00:00
fixed landing on home page upon deleting, and replaced "origin" value with "source" as origin is a global
This commit is contained in:
1 parent
8b489e9650
commit
27887e2278
15 files changed
+50
-61
No files matched your search
@@ -13,14 +13,15 @@ import useWeightTypeInfo from "hooks/useWeightTypeInfo/useWeightTypeInfo";
|
||||
import WeightCoverImage from "components/common/WeightCoverImage";
|
||||
import { BucketConfig } from "@storyteller/components/src/api/BucketConfig";
|
||||
import useToken from "hooks/useToken";
|
||||
import getCardUrl from "../getCardUrl";
|
||||
|
||||
interface AudioCardProps {
|
||||
bookmarks?: any;
|
||||
data: any;
|
||||
origin?: string;
|
||||
ratings?: any;
|
||||
showCreator?: boolean;
|
||||
showCover?: boolean;
|
||||
source?: string;
|
||||
type: "media" | "weights";
|
||||
inSelectModal?: boolean;
|
||||
onResultSelect?: () => void;
|
||||
@@ -29,22 +30,17 @@ interface AudioCardProps {
|
||||
export default function AudioCard({
|
||||
bookmarks,
|
||||
data,
|
||||
origin = "",
|
||||
ratings,
|
||||
showCreator,
|
||||
showCover,
|
||||
source = "",
|
||||
type,
|
||||
inSelectModal = false,
|
||||
onResultSelect,
|
||||
}: AudioCardProps) {
|
||||
const { setToken, setWeightTitle } = useToken();
|
||||
const linkUrl = getCardUrl(data,source,type);
|
||||
const history = useHistory();
|
||||
const linkUrl =
|
||||
type === "media"
|
||||
? `/media/${data.token}`
|
||||
: `/weight/${data.weight_token || data.details.entity_token}${
|
||||
origin ? "?origin=" + origin : ""
|
||||
}`;
|
||||
|
||||
const handleInnerClick = (event: any) => {
|
||||
event.stopPropagation();
|
||||
@@ -257,8 +253,7 @@ export default function AudioCard({
|
||||
) : (
|
||||
<Link
|
||||
{...{
|
||||
to: linkUrl,
|
||||
state: { origin },
|
||||
to: linkUrl
|
||||
}}
|
||||
>
|
||||
{card}
|
||||
|
||||
@@ -11,13 +11,14 @@ import { faArrowRight } from "@fortawesome/pro-solid-svg-icons";
|
||||
import useWeightTypeInfo from "hooks/useWeightTypeInfo/useWeightTypeInfo";
|
||||
import { BucketConfig } from "@storyteller/components/src/api/BucketConfig";
|
||||
import useToken from "hooks/useToken";
|
||||
import getCardUrl from "../getCardUrl";
|
||||
|
||||
interface ImageCardProps {
|
||||
bookmarks?: any;
|
||||
data: any;
|
||||
origin?: string;
|
||||
ratings?: any;
|
||||
showCreator?: boolean;
|
||||
source?: string;
|
||||
type: "media" | "weights";
|
||||
inSelectModal?: boolean;
|
||||
onResultSelect?: () => void;
|
||||
@@ -26,8 +27,8 @@ interface ImageCardProps {
|
||||
export default function ImageCard({
|
||||
bookmarks,
|
||||
data,
|
||||
origin = "",
|
||||
showCreator,
|
||||
source = "",
|
||||
ratings,
|
||||
type,
|
||||
inSelectModal = false,
|
||||
@@ -35,12 +36,7 @@ export default function ImageCard({
|
||||
}: ImageCardProps) {
|
||||
const history = useHistory();
|
||||
const { setToken, setWeightTitle } = useToken();
|
||||
const linkUrl =
|
||||
type === "media"
|
||||
? `/media/${data.token}`
|
||||
: `/weight/${data.weight_token || data.details.entity_token}${
|
||||
origin ? "?origin=" + origin : ""
|
||||
}`;
|
||||
const linkUrl = getCardUrl(data,source,type);
|
||||
|
||||
const handleInnerClick = (event: any) => {
|
||||
event.stopPropagation();
|
||||
@@ -268,7 +264,6 @@ export default function ImageCard({
|
||||
<Link
|
||||
{...{
|
||||
to: linkUrl,
|
||||
state: { origin },
|
||||
}}
|
||||
>
|
||||
{card}
|
||||
|
||||
@@ -7,31 +7,27 @@ import LikeButton from "components/common/LikeButton";
|
||||
import CreatorName from "../CreatorName";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faPersonWalking } from "@fortawesome/pro-solid-svg-icons";
|
||||
import getCardUrl from "../getCardUrl";
|
||||
// import { BucketConfig } from "@storyteller/components/src/api/BucketConfig";
|
||||
|
||||
interface ImageCardProps {
|
||||
bookmarks: any;
|
||||
data: any;
|
||||
origin?: string;
|
||||
ratings: any;
|
||||
showCreator?: boolean;
|
||||
source?: string;
|
||||
type: "media" | "weights";
|
||||
}
|
||||
|
||||
export default function ImageCard({
|
||||
bookmarks,
|
||||
data,
|
||||
origin = "",
|
||||
showCreator,
|
||||
source = "",
|
||||
ratings,
|
||||
type,
|
||||
}: ImageCardProps) {
|
||||
const linkUrl =
|
||||
type === "media"
|
||||
? `/media/${data.token}`
|
||||
: `/weight/${data.weight_token || data.details.entity_token}${
|
||||
origin ? "?origin=" + origin : ""
|
||||
}`;
|
||||
const linkUrl = getCardUrl(data,source,type);
|
||||
|
||||
const handleInnerClick = (event: any) => {
|
||||
event.stopPropagation();
|
||||
@@ -44,8 +40,7 @@ export default function ImageCard({
|
||||
return (
|
||||
<Link
|
||||
{...{
|
||||
to: linkUrl,
|
||||
state: { origin },
|
||||
to: linkUrl
|
||||
}}
|
||||
>
|
||||
<Card padding={false} canHover={true}>
|
||||
|
||||
@@ -10,12 +10,13 @@ import CreatorName from "../CreatorName";
|
||||
import { BucketConfig } from "@storyteller/components/src/api/BucketConfig";
|
||||
import { Link } from "react-router-dom";
|
||||
import useToken from "hooks/useToken";
|
||||
import getCardUrl from "../getCardUrl";
|
||||
|
||||
interface VideoCardProps {
|
||||
data: any;
|
||||
origin?: string;
|
||||
ratings?: any;
|
||||
showCreator?: boolean;
|
||||
source?: string;
|
||||
type: "media" | "weights";
|
||||
inSelectModal?: boolean;
|
||||
onResultSelect?: () => void;
|
||||
@@ -23,16 +24,15 @@ interface VideoCardProps {
|
||||
|
||||
export default function VideoCard({
|
||||
data,
|
||||
origin = "",
|
||||
ratings,
|
||||
showCreator,
|
||||
source = "",
|
||||
type,
|
||||
inSelectModal = false,
|
||||
onResultSelect,
|
||||
}: VideoCardProps) {
|
||||
const { setToken, setWeightTitle } = useToken();
|
||||
const linkUrl =
|
||||
type === "media" ? `/media/${data.token}` : `/weight/${data.weight_token}`;
|
||||
const linkUrl = getCardUrl(data,source,type);
|
||||
|
||||
const handleInnerClick = (event: any) => {
|
||||
event.stopPropagation();
|
||||
@@ -197,7 +197,6 @@ export default function VideoCard({
|
||||
<Link
|
||||
{...{
|
||||
to: linkUrl,
|
||||
state: { origin },
|
||||
}}
|
||||
>
|
||||
{card}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
const getCardUrl = (data: any, source: string, type: string) => {
|
||||
let prefix = type === "media" ? `/media/${data.token}` : `/weight/${data.weight_token || data.details?.entity_token}`;
|
||||
let suffix = source ? "?source=" + source : "";
|
||||
return prefix + suffix;
|
||||
}
|
||||
|
||||
export default getCardUrl;
|
||||
@@ -13,7 +13,6 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function SessionProvider({ children, querySession, querySubscriptions, sessionFetched, sessionWrapper }: Props) {
|
||||
console.log("🥕",sessionWrapper);
|
||||
const sessionResponse = sessionWrapper?.sessionStateResponse || { logged_in: false };
|
||||
const { logged_in: loggedIn, user } = sessionResponse;
|
||||
const [view,viewSet] = useState(ModalView.Closed);
|
||||
|
||||
@@ -9,7 +9,6 @@ export default function useRatings() {
|
||||
entity_type,
|
||||
rating_value: lib[entity_token]?.rating_value !== "positive" ? "positive" : "neutral"
|
||||
}
|
||||
// console.log("😎",lib[entity_token], newRating);
|
||||
return SetRating("", newRating);
|
||||
};
|
||||
|
||||
@@ -27,15 +26,12 @@ export default function useRatings() {
|
||||
const ratings = useBatchContent({
|
||||
fetcher: GetRatings,
|
||||
checker: () => true,
|
||||
debug: "useRatings",
|
||||
// debug: "useRatings",
|
||||
modLibrary: (current: any, res: any, entity_token: string, tokenType: string) => {
|
||||
console.log("🪼", tokenType, res );
|
||||
let { positive_rating_count } = res.results ? res.results.find((item: any, i: number) =>
|
||||
item[tokenType] === entity_token
|
||||
).stats : res.stats;
|
||||
|
||||
console.log("🐽",positive_rating_count);
|
||||
|
||||
return { ...current, positive_rating_count };
|
||||
},
|
||||
onFail: { fetch, modLibrary },
|
||||
@@ -44,8 +40,6 @@ export default function useRatings() {
|
||||
toggleCheck: (entity: any) => (entity?.rating_value || "") === "positive"
|
||||
});
|
||||
|
||||
// console.log("🍎",ratings.busyList);
|
||||
|
||||
return {
|
||||
...ratings,
|
||||
makeProps: ({ entityToken, entityType }: { entityToken: string, entityType: string }) => ({
|
||||
|
||||
@@ -55,10 +55,10 @@ export default function useWeightFetch({ onRemove = n, onSuccess = n, token }: P
|
||||
});
|
||||
};
|
||||
|
||||
const remove = () => {
|
||||
const remove = (as_mod: boolean) => {
|
||||
writeStatusSet(FetchStatus.in_progress);
|
||||
DeleteWeight(token, {
|
||||
as_mod: true,
|
||||
as_mod,
|
||||
set_delete: true,
|
||||
}).then((res: any) => {
|
||||
writeStatusSet(FetchStatus.success);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import MasonryGrid from "components/common/MasonryGrid/MasonryGrid";
|
||||
import MediaCards from "components/common/Card/MediaCards";
|
||||
import { Link } from "react-router-dom";
|
||||
@@ -13,6 +14,7 @@ import SkeletonCard from "components/common/Card/SkeletonCard";
|
||||
import "./FeaturedTab.scss";
|
||||
|
||||
export default function FeaturedTab() {
|
||||
const { pathname: source } = useLocation();
|
||||
const bookmarks = useBookmarks();
|
||||
const ratings = useRatings();
|
||||
const gridContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
@@ -83,10 +85,10 @@ export default function FeaturedTab() {
|
||||
let props = {
|
||||
bookmarks,
|
||||
data,
|
||||
origin,
|
||||
ratings,
|
||||
type: "media",
|
||||
showCreator: true,
|
||||
source,
|
||||
type: "media",
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -16,7 +16,7 @@ import InfiniteScroll from "react-infinite-scroll-component";
|
||||
import prepFilter from "resources/prepFilter";
|
||||
|
||||
export default function MediaTab() {
|
||||
const { search } = useLocation();
|
||||
const { pathname: source, search } = useLocation();
|
||||
const urlQueries = new URLSearchParams(search);
|
||||
const bookmarks = useBookmarks();
|
||||
const ratings = useRatings();
|
||||
@@ -33,7 +33,7 @@ export default function MediaTab() {
|
||||
...prepFilter(mediaType, "filter_media_type"),
|
||||
},
|
||||
addSetters: { mediaTypeSet },
|
||||
debug: "explore media tab",
|
||||
// debug: "explore media tab",
|
||||
fetcher: ListMediaFiles,
|
||||
list,
|
||||
listSet,
|
||||
@@ -125,7 +125,7 @@ export default function MediaTab() {
|
||||
let props = {
|
||||
bookmarks,
|
||||
data,
|
||||
origin,
|
||||
source,
|
||||
ratings,
|
||||
type: "media",
|
||||
showCreator: true,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { useBookmarks, useLazyLists, useRatings } from "hooks";
|
||||
import prepFilter from "resources/prepFilter";
|
||||
|
||||
export default function WeightsTab() {
|
||||
const { search } = useLocation();
|
||||
const { pathname: source, search } = useLocation();
|
||||
const urlQueries = new URLSearchParams(search);
|
||||
const bookmarks = useBookmarks();
|
||||
const ratings = useRatings();
|
||||
@@ -188,6 +188,7 @@ export default function WeightsTab() {
|
||||
let props = {
|
||||
bookmarks,
|
||||
data,
|
||||
source,
|
||||
ratings,
|
||||
showCreator: true,
|
||||
type: "weights",
|
||||
|
||||
@@ -15,7 +15,7 @@ import WeightsCards from "components/common/Card/WeightsCards";
|
||||
import prepFilter from "resources/prepFilter";
|
||||
|
||||
export default function BookmarksTab({ username }: { username: string }) {
|
||||
const { pathname: origin, search } = useLocation();
|
||||
const { pathname: source, search } = useLocation();
|
||||
const urlQueries = new URLSearchParams(search);
|
||||
const bookmarks = useBookmarks();
|
||||
const ratings = useRatings();
|
||||
@@ -52,7 +52,7 @@ export default function BookmarksTab({ username }: { username: string }) {
|
||||
...prepFilter(weightCategory, "maybe_scoped_weight_category"),
|
||||
},
|
||||
addSetters: { sdSet, ttsSet, vcSet, weightCategorySet, weightTypeSet },
|
||||
debug: "bookmarks tab",
|
||||
// debug: "bookmarks tab",
|
||||
fetcher: GetBookmarksByUser,
|
||||
list,
|
||||
listSet,
|
||||
@@ -209,7 +209,7 @@ export default function BookmarksTab({ username }: { username: string }) {
|
||||
onLayoutComplete={() => console.log("Layout complete!")}
|
||||
>
|
||||
{dataList.map((data: any, key: number) => {
|
||||
let weightProps = { bookmarks, data, origin, ratings, showCreator: true, type: "weights" };
|
||||
let weightProps = { bookmarks, data, ratings, showCreator: true, source, type: "weights" };
|
||||
|
||||
// let mediaProps = {
|
||||
// bookmarks,
|
||||
|
||||
@@ -17,7 +17,7 @@ import { useListContent, useRatings } from "hooks";
|
||||
import prepFilter from "resources/prepFilter";
|
||||
|
||||
export default function MediaTab({ username }: { username: string }) {
|
||||
const { pathname: origin, search } = useLocation();
|
||||
const { pathname: source, search } = useLocation();
|
||||
const urlQueries = new URLSearchParams(search);
|
||||
// const bookmarks = useBookmarks();
|
||||
const ratings = useRatings();
|
||||
@@ -33,7 +33,7 @@ export default function MediaTab({ username }: { username: string }) {
|
||||
...prepFilter(mediaType, "filter_media_type"),
|
||||
},
|
||||
addSetters: { mediaTypeSet },
|
||||
debug: "profile media",
|
||||
// debug: "profile media",
|
||||
fetcher: GetMediaByUser,
|
||||
list,
|
||||
listSet,
|
||||
@@ -116,7 +116,7 @@ export default function MediaTab({ username }: { username: string }) {
|
||||
onLayoutComplete={() => console.log("Layout complete!")}
|
||||
>
|
||||
{media.list.map((data: MediaFile, key: number) => {
|
||||
let props = { data, origin, ratings, type: "media" };
|
||||
let props = { data, source, ratings, type: "media" };
|
||||
return (
|
||||
<div
|
||||
{...{
|
||||
|
||||
@@ -23,7 +23,7 @@ import prepFilter from "resources/prepFilter";
|
||||
// }
|
||||
|
||||
export default function WeightsTab({ username }: { username: string }) {
|
||||
const { pathname: origin, search } = useLocation();
|
||||
const { pathname: source, search } = useLocation();
|
||||
// const { maybe_scoped_weight_type, ...yadda } = useParams<{ maybe_scoped_weight_type: string }>();
|
||||
const urlQueries = new URLSearchParams(search);
|
||||
const gridContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
@@ -198,7 +198,7 @@ export default function WeightsTab({ username }: { username: string }) {
|
||||
onLayoutComplete={() => console.log("Layout complete!")}
|
||||
>
|
||||
{weights.list.map((data: any, key: number) => {
|
||||
let props = { bookmarks, data, origin, ratings, showCreator: true, type: "weights" };
|
||||
let props = { bookmarks, data, ratings, showCreator: true, type: "weights", source };
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -59,7 +59,7 @@ export default function WeightPage({
|
||||
const { canEditTtsModel, user } = useSession();
|
||||
const { search } = useLocation();
|
||||
const { weight_token } = useParams<{ weight_token: string }>();
|
||||
const origin = search ? new URLSearchParams(search).get("origin") : "";
|
||||
const source = search ? new URLSearchParams(search).get("source") : "";
|
||||
const history = useHistory();
|
||||
const bookmarks = useBookmarks();
|
||||
const ratings = useRatings();
|
||||
@@ -72,7 +72,7 @@ export default function WeightPage({
|
||||
remove,
|
||||
} = useWeightFetch({
|
||||
onRemove: () => {
|
||||
history.push(origin || "");
|
||||
history.push(source || "");
|
||||
},
|
||||
onSuccess: (res: any) => {
|
||||
bookmarks.gather({ res, key: "weight_token" }); // expand rather than replace for lazy loading
|
||||
@@ -98,6 +98,8 @@ export default function WeightPage({
|
||||
fullLabel: weightTypeFull,
|
||||
} = weightTypeInfo;
|
||||
|
||||
const deleteWeight = () => remove(!!user?.can_ban_users);
|
||||
|
||||
function renderWeightComponent(weight: Weight) {
|
||||
switch (weight.weight_category) {
|
||||
case WeightCategory.TTS:
|
||||
@@ -570,7 +572,7 @@ export default function WeightPage({
|
||||
content={() => (
|
||||
<>{`Are you sure you want to delete "${title}"? This action cannot be undone.`}</>
|
||||
)}
|
||||
onConfirm={remove}
|
||||
onConfirm={deleteWeight}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user