@@ -3,7 +3,7 @@ import { useView } from '@renderer/hooks/search';
33import { useAppDispatch , useAppSelector } from '@renderer/hooks/useAppSelector' ;
44import { useLocalization } from '@renderer/hooks/useLocalization' ;
55import { addRandomGames , RANDOM_GAME_ROW_COUNT , setMainState } from '@renderer/store/main/slice' ;
6- import { GENERAL_VIEW_ID , searchActions , selectGame } from '@renderer/store/search/slice' ;
6+ import { forceSearch , GENERAL_VIEW_ID , selectGame , setSearchText } from '@renderer/store/search/slice' ;
77import { findGameDragEventDataGrid , getExtremeIconURL , getPlatformIconURL , joinLibraryRoute } from '@renderer/Util' ;
88import { idToGame } from '@renderer/util/async' ;
99import { BackIn } from '@shared/back/types' ;
@@ -368,27 +368,32 @@ export function HomePageComponentRandomGames(props: HomePageComponentProps) {
368368
369369export function HomePageComponentExtras ( props : HomePageComponentProps ) {
370370 const { toggleMinimizeBox } = props ;
371+ const dispatch = useAppDispatch ( ) ;
372+ const useCustomViews = useAppSelector ( state => state . preferences . useCustomViews ) ;
371373 const minimized = useAppSelector ( state => state . preferences . minimizedHomePageBoxes . includes ( 'extras' ) ) ;
372374 const logoVersion = useAppSelector ( state => state . main . logoVersion ) ;
373- const viewObj = useAppSelector ( ( state ) => state . search . views ) ;
375+ const firstValidView = useAppSelector ( ( state ) => {
376+ for ( const key in state . search . views ) {
377+ if ( key !== GENERAL_VIEW_ID && ! key . startsWith ( '!fpfss' ) ) {
378+ return key ;
379+ }
380+ }
381+ return null ;
382+ } ) ;
374383 const platforms = useAppSelector ( state => state . main . suggestions . platforms ) ;
375384 const allStrings = useLocalization ( ) ;
376385 const strings = allStrings . home ;
377-
378- const views = Object . keys ( viewObj ) ;
379- let viewName = '' ;
380- for ( const view of views ) {
381- if ( view !== GENERAL_VIEW_ID ) {
382- viewName = view ;
383- break ;
384- }
385- }
386-
387386 const onSearchPlatform = ( platform : string ) => {
388- searchActions . setSearchText ( {
389- view : viewName ,
390- text : `platform:"${ platform } "`
391- } ) ;
387+ if ( firstValidView !== null ) {
388+ dispatch ( setSearchText ( {
389+ view : firstValidView ,
390+ text : `platform:"${ platform } "`
391+ } ) ) ;
392+ dispatch ( forceSearch ( {
393+ view : firstValidView ,
394+ useCustomViews,
395+ } ) ) ;
396+ }
392397 } ;
393398
394399 const sortedPlatforms = [ ...platforms ] . sort ( ( a , b ) => a . toLowerCase ( ) . localeCompare ( b . toLowerCase ( ) ) ) ;
@@ -408,7 +413,7 @@ export function HomePageComponentExtras(props: HomePageComponentProps) {
408413 < Link
409414 key = { idx }
410415 className = 'home-page__platform-entry'
411- to = { joinLibraryRoute ( viewName ) }
416+ to = { joinLibraryRoute ( firstValidView || GENERAL_VIEW_ID ) }
412417 onClick = { ( ) => onSearchPlatform ( platform ) } >
413418 < div
414419 className = 'home-page__platform-entry__logo'
0 commit comments