mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Details pages start with populated content tab (#4032)
This commit is contained in:
@@ -57,6 +57,7 @@ interface IPerformerParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const validTabs = [
|
const validTabs = [
|
||||||
|
"default",
|
||||||
"scenes",
|
"scenes",
|
||||||
"galleries",
|
"galleries",
|
||||||
"images",
|
"images",
|
||||||
@@ -65,7 +66,7 @@ const validTabs = [
|
|||||||
] as const;
|
] as const;
|
||||||
type TabKey = (typeof validTabs)[number];
|
type TabKey = (typeof validTabs)[number];
|
||||||
|
|
||||||
const defaultTab: TabKey = "scenes";
|
const defaultTab: TabKey = "default";
|
||||||
|
|
||||||
function isTabKey(tab: string): tab is TabKey {
|
function isTabKey(tab: string): tab is TabKey {
|
||||||
return validTabs.includes(tab as TabKey);
|
return validTabs.includes(tab as TabKey);
|
||||||
@@ -117,11 +118,30 @@ const PerformerPage: React.FC<IProps> = ({ performer, tabKey }) => {
|
|||||||
const [updatePerformer] = usePerformerUpdate();
|
const [updatePerformer] = usePerformerUpdate();
|
||||||
const [deletePerformer, { loading: isDestroying }] = usePerformerDestroy();
|
const [deletePerformer, { loading: isDestroying }] = usePerformerDestroy();
|
||||||
|
|
||||||
|
const populatedDefaultTab = useMemo(() => {
|
||||||
|
let ret: TabKey = "scenes";
|
||||||
|
if (performer.scene_count == 0) {
|
||||||
|
if (performer.gallery_count != 0) {
|
||||||
|
ret = "galleries";
|
||||||
|
} else if (performer.image_count != 0) {
|
||||||
|
ret = "images";
|
||||||
|
} else if (performer.movie_count != 0) {
|
||||||
|
ret = "movies";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}, [performer]);
|
||||||
|
|
||||||
|
if (tabKey === defaultTab) {
|
||||||
|
tabKey = populatedDefaultTab;
|
||||||
|
}
|
||||||
|
|
||||||
function setTabKey(newTabKey: string | null) {
|
function setTabKey(newTabKey: string | null) {
|
||||||
if (!newTabKey) newTabKey = defaultTab;
|
if (!newTabKey || newTabKey === defaultTab) newTabKey = populatedDefaultTab;
|
||||||
if (newTabKey === tabKey) return;
|
if (newTabKey === tabKey) return;
|
||||||
|
|
||||||
if (newTabKey === defaultTab) {
|
if (newTabKey === populatedDefaultTab) {
|
||||||
history.replace(`/performers/${performer.id}`);
|
history.replace(`/performers/${performer.id}`);
|
||||||
} else if (isTabKey(newTabKey)) {
|
} else if (isTabKey(newTabKey)) {
|
||||||
history.replace(`/performers/${performer.id}/${newTabKey}`);
|
history.replace(`/performers/${performer.id}/${newTabKey}`);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Button, Tabs, Tab } from "react-bootstrap";
|
import { Button, Tabs, Tab } from "react-bootstrap";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import { useHistory, Redirect, RouteComponentProps } from "react-router-dom";
|
import { useHistory, Redirect, RouteComponentProps } from "react-router-dom";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
import { Helmet } from "react-helmet";
|
import { Helmet } from "react-helmet";
|
||||||
@@ -57,6 +57,7 @@ interface IStudioParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const validTabs = [
|
const validTabs = [
|
||||||
|
"default",
|
||||||
"scenes",
|
"scenes",
|
||||||
"galleries",
|
"galleries",
|
||||||
"images",
|
"images",
|
||||||
@@ -66,7 +67,7 @@ const validTabs = [
|
|||||||
] as const;
|
] as const;
|
||||||
type TabKey = (typeof validTabs)[number];
|
type TabKey = (typeof validTabs)[number];
|
||||||
|
|
||||||
const defaultTab: TabKey = "scenes";
|
const defaultTab: TabKey = "default";
|
||||||
|
|
||||||
function isTabKey(tab: string): tab is TabKey {
|
function isTabKey(tab: string): tab is TabKey {
|
||||||
return validTabs.includes(tab as TabKey);
|
return validTabs.includes(tab as TabKey);
|
||||||
@@ -112,6 +113,36 @@ const StudioPage: React.FC<IProps> = ({ studio, tabKey }) => {
|
|||||||
const movieCount =
|
const movieCount =
|
||||||
(showAllCounts ? studio.movie_count_all : studio.movie_count) ?? 0;
|
(showAllCounts ? studio.movie_count_all : studio.movie_count) ?? 0;
|
||||||
|
|
||||||
|
const populatedDefaultTab = useMemo(() => {
|
||||||
|
let ret: TabKey = "scenes";
|
||||||
|
if (sceneCount == 0) {
|
||||||
|
if (galleryCount != 0) {
|
||||||
|
ret = "galleries";
|
||||||
|
} else if (imageCount != 0) {
|
||||||
|
ret = "images";
|
||||||
|
} else if (performerCount != 0) {
|
||||||
|
ret = "performers";
|
||||||
|
} else if (movieCount != 0) {
|
||||||
|
ret = "movies";
|
||||||
|
} else if (studio.child_studios.length != 0) {
|
||||||
|
ret = "childstudios";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}, [
|
||||||
|
sceneCount,
|
||||||
|
galleryCount,
|
||||||
|
imageCount,
|
||||||
|
performerCount,
|
||||||
|
movieCount,
|
||||||
|
studio,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (tabKey === defaultTab) {
|
||||||
|
tabKey = populatedDefaultTab;
|
||||||
|
}
|
||||||
|
|
||||||
// set up hotkeys
|
// set up hotkeys
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Mousetrap.bind("e", () => toggleEditing());
|
Mousetrap.bind("e", () => toggleEditing());
|
||||||
@@ -243,10 +274,10 @@ const StudioPage: React.FC<IProps> = ({ studio, tabKey }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setTabKey(newTabKey: string | null) {
|
function setTabKey(newTabKey: string | null) {
|
||||||
if (!newTabKey) newTabKey = defaultTab;
|
if (!newTabKey || newTabKey === defaultTab) newTabKey = populatedDefaultTab;
|
||||||
if (newTabKey === tabKey) return;
|
if (newTabKey === tabKey) return;
|
||||||
|
|
||||||
if (newTabKey === defaultTab) {
|
if (newTabKey === populatedDefaultTab) {
|
||||||
history.replace(`/studios/${studio.id}`);
|
history.replace(`/studios/${studio.id}`);
|
||||||
} else if (isTabKey(newTabKey)) {
|
} else if (isTabKey(newTabKey)) {
|
||||||
history.replace(`/studios/${studio.id}/${newTabKey}`);
|
history.replace(`/studios/${studio.id}/${newTabKey}`);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Tabs, Tab, Dropdown, Button } from "react-bootstrap";
|
import { Tabs, Tab, Dropdown, Button } from "react-bootstrap";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import { useHistory, Redirect, RouteComponentProps } from "react-router-dom";
|
import { useHistory, Redirect, RouteComponentProps } from "react-router-dom";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
import { Helmet } from "react-helmet";
|
import { Helmet } from "react-helmet";
|
||||||
@@ -53,6 +53,7 @@ interface ITagParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const validTabs = [
|
const validTabs = [
|
||||||
|
"default",
|
||||||
"scenes",
|
"scenes",
|
||||||
"images",
|
"images",
|
||||||
"galleries",
|
"galleries",
|
||||||
@@ -61,7 +62,7 @@ const validTabs = [
|
|||||||
] as const;
|
] as const;
|
||||||
type TabKey = (typeof validTabs)[number];
|
type TabKey = (typeof validTabs)[number];
|
||||||
|
|
||||||
const defaultTab: TabKey = "scenes";
|
const defaultTab: TabKey = "default";
|
||||||
|
|
||||||
function isTabKey(tab: string): tab is TabKey {
|
function isTabKey(tab: string): tab is TabKey {
|
||||||
return validTabs.includes(tab as TabKey);
|
return validTabs.includes(tab as TabKey);
|
||||||
@@ -107,11 +108,32 @@ const TagPage: React.FC<IProps> = ({ tag, tabKey }) => {
|
|||||||
const performerCount =
|
const performerCount =
|
||||||
(showAllCounts ? tag.performer_count_all : tag.performer_count) ?? 0;
|
(showAllCounts ? tag.performer_count_all : tag.performer_count) ?? 0;
|
||||||
|
|
||||||
|
const populatedDefaultTab = useMemo(() => {
|
||||||
|
let ret: TabKey = "scenes";
|
||||||
|
if (sceneCount == 0) {
|
||||||
|
if (imageCount != 0) {
|
||||||
|
ret = "images";
|
||||||
|
} else if (galleryCount != 0) {
|
||||||
|
ret = "galleries";
|
||||||
|
} else if (sceneMarkerCount != 0) {
|
||||||
|
ret = "markers";
|
||||||
|
} else if (performerCount != 0) {
|
||||||
|
ret = "performers";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}, [sceneCount, imageCount, galleryCount, sceneMarkerCount, performerCount]);
|
||||||
|
|
||||||
|
if (tabKey === defaultTab) {
|
||||||
|
tabKey = populatedDefaultTab;
|
||||||
|
}
|
||||||
|
|
||||||
function setTabKey(newTabKey: string | null) {
|
function setTabKey(newTabKey: string | null) {
|
||||||
if (!newTabKey) newTabKey = defaultTab;
|
if (!newTabKey || newTabKey === defaultTab) newTabKey = populatedDefaultTab;
|
||||||
if (newTabKey === tabKey) return;
|
if (newTabKey === tabKey) return;
|
||||||
|
|
||||||
if (newTabKey === defaultTab) {
|
if (newTabKey === populatedDefaultTab) {
|
||||||
history.replace(`/tags/${tag.id}`);
|
history.replace(`/tags/${tag.id}`);
|
||||||
} else if (isTabKey(newTabKey)) {
|
} else if (isTabKey(newTabKey)) {
|
||||||
history.replace(`/tags/${tag.id}/${newTabKey}`);
|
history.replace(`/tags/${tag.id}/${newTabKey}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user