Separate search clear effect from config saving (#6247)

Fixes Scrape results cache eviction in tagger view
This commit is contained in:
WithoutPants 2025-11-07 15:11:17 +11:00 committed by GitHub
parent 96a7e087f2
commit d52b6afd4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -173,6 +173,7 @@ export const TaggerContext: React.FC = ({ children }) => {
setSources(stashboxSources.concat(scraperSources));
}, [Scrapers.data, stashConfig]);
// set the current source on load
useEffect(() => {
if (!sources.length || currentSource) {
return;
@ -191,8 +192,13 @@ export const TaggerContext: React.FC = ({ children }) => {
setCurrentSource(sources[0]);
}, [sources, currentSource, config]);
// clear the search results when the source changes
useEffect(() => {
setSearchResults({});
}, [currentSource]);
// keep selected endpoint in config in sync with current source
useEffect(() => {
const selectedEndpoint = currentSource?.sourceInput.stash_box_endpoint;
if (selectedEndpoint && selectedEndpoint !== config.selectedEndpoint) {
setConfig({