@@ -26,7 +26,6 @@ import type { Emitter } from "mitt";
2626import { inject } from "vue" ;
2727import type { ScanStats } from "@/__generated__" ;
2828import platformApi from "@/services/api/platform" ;
29- import storeGalleryFilter from "@/stores/galleryFilter" ;
3029import storePlatforms from "@/stores/platforms" ;
3130import storeRoms , { type SimpleRom } from "@/stores/roms" ;
3231import storeScanning , { type ScanningPlatform } from "@/stores/scanning" ;
@@ -38,7 +37,6 @@ export function installScanLifecycle() {
3837 const scanningStore = storeScanning ( ) ;
3938 const romsStore = storeRoms ( ) ;
4039 const platformsStore = storePlatforms ( ) ;
41- const galleryFilterStore = storeGalleryFilter ( ) ;
4240 const galleryRomsStore = storeGalleryRoms ( ) ;
4341 const emitter = inject < Emitter < Events > > ( "emitter" ) ;
4442
@@ -91,6 +89,14 @@ export function installScanLifecycle() {
9189 // ROM. Queue drains every 100ms; matches the v1 behavior. Stored
9290 // outside the handler so multiple events share the same queue + flush.
9391 const romUpdateQueue : SimpleRom [ ] = [ ] ;
92+ const refreshGallery = debounce (
93+ ( ) => {
94+ galleryRomsStore . invalidateWindows ( ) ;
95+ void galleryRomsStore . fetchInitialMetadata ( ) ;
96+ } ,
97+ 250 ,
98+ { maxWait : 1000 } ,
99+ ) ;
94100 const processRomUpdates = debounce ( ( ) => {
95101 if ( romUpdateQueue . length === 0 ) return ;
96102 const updates = romUpdateQueue . splice ( 0 , romUpdateQueue . length ) ;
@@ -101,13 +107,9 @@ export function installScanLifecycle() {
101107 romsStore . addToRecent ( rom ) ;
102108
103109 // If the user is currently looking at the gallery of the platform
104- // being scanned, fold the new ROM into the visible list.
105- if (
106- galleryRomsStore . currentPlatform ?. id === rom . platform_id &&
107- ! galleryFilterStore . searchTerm &&
108- ! galleryFilterStore . isFiltered ( )
109- ) {
110- galleryRomsStore . addLiveRom ( rom ) ;
110+ // being scanned, refresh from the server to preserve sorting/filtering.
111+ if ( galleryRomsStore . currentPlatform ?. id === rom . platform_id ) {
112+ refreshGallery ( ) ;
111113 }
112114 if ( romsStore . currentPlatform ?. id === rom . platform_id ) {
113115 const existing = romsStore . filteredRoms . find ( ( r ) => r . id === rom . id ) ;
0 commit comments