Auto-populate query string into name on create

This commit is contained in:
WithoutPants 2026-02-04 14:47:29 +11:00
parent eeeda9fc04
commit de86ec89d5
2 changed files with 16 additions and 4 deletions

View file

@ -1,7 +1,7 @@
import React, { useCallback, useEffect } from "react";
import { FormattedMessage, useIntl } from "react-intl";
import cloneDeep from "lodash-es/cloneDeep";
import { useHistory } from "react-router-dom";
import { useHistory, useLocation } from "react-router-dom";
import Mousetrap from "mousetrap";
import * as GQL from "src/core/generated-graphql";
import { useFilteredItemList } from "../List/ItemList";
@ -226,6 +226,7 @@ function useAddKeybinds(filter: ListFilterModel, count: number) {
export const FilteredGalleryList = (props: IGalleryList) => {
const intl = useIntl();
const history = useHistory();
const location = useLocation();
const searchFocus = useFocus();
@ -310,7 +311,12 @@ export const FilteredGalleryList = (props: IGalleryList) => {
});
function onCreateNew() {
history.push("/galleries/new");
let queryParam = new URLSearchParams(location.search).get("q");
let newPath = "/galleries/new";
if (queryParam) {
newPath += "?q=" + encodeURIComponent(queryParam);
}
history.push(newPath);
}
const viewRandom = useViewRandom(filter, totalCount);

View file

@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useMemo } from "react";
import cloneDeep from "lodash-es/cloneDeep";
import { FormattedMessage, useIntl } from "react-intl";
import { useHistory } from "react-router-dom";
import { useHistory, useLocation } from "react-router-dom";
import Mousetrap from "mousetrap";
import * as GQL from "src/core/generated-graphql";
import { queryFindScenes, useFindScenes } from "src/core/StashService";
@ -343,6 +343,7 @@ interface IFilteredScenes {
export const FilteredSceneList = (props: IFilteredScenes) => {
const intl = useIntl();
const history = useHistory();
const location = useLocation();
const searchFocus = useFocus();
@ -459,7 +460,12 @@ export const FilteredSceneList = (props: IFilteredScenes) => {
const playFirst = usePlayFirst();
function onCreateNew() {
history.push("/scenes/new");
let queryParam = new URLSearchParams(location.search).get("q");
let newPath = "/scenes/new";
if (queryParam) {
newPath += "?q=" + encodeURIComponent(queryParam);
}
history.push(newPath);
}
function onPlay() {