@@ -4,17 +4,23 @@ import {
44 GeneratedEntrypointAction ,
55} from "@project-gauntlet/api/helpers" ;
66import { linux_open_application } from "gauntlet:bridge/internal-linux" ;
7+ import { useState } from "react" ;
78import { Action , ActionPanel , List } from "@project-gauntlet/api/components" ;
89
9- export function ListOfWindows ( { windows, focusWindow } : {
10+ export function ListOfWindows ( { windows, focusWindow, focusSecond } : {
1011 windows : Record < string , OpenWindowData > ,
11- focusWindow : ( windowId : string ) => void
12+ focusWindow : ( windowId : string ) => void ,
13+ focusSecond : boolean
1214} ) {
1315 const knownWindows = readWindowOrder ( ) ;
1416
1517 const sortedWindows = Object . keys ( windows ) // sort windows based on array stored on storage
1618 . sort ( ( a , b ) => knownWindows . indexOf ( a ) - knownWindows . indexOf ( b ) ) ;
1719
20+ const [ id , setId ] = useState < string | null > (
21+ focusSecond ? sortedWindows . at ( 1 ) || null : null
22+ ) ;
23+
1824 return (
1925 < List
2026 actions = {
@@ -30,6 +36,8 @@ export function ListOfWindows({ windows, focusWindow }: {
3036 />
3137 </ ActionPanel >
3238 }
39+ onItemFocusChange = { setId }
40+ focusedItemId = { id }
3341 >
3442 {
3543 sortedWindows . map ( window => < List . Item key = { window } id = { window } title = { windows [ window ] ! ! . title } /> )
@@ -112,6 +120,7 @@ export function applicationActions(
112120 < ListOfWindows
113121 windows = { appWindows }
114122 focusWindow = { windowId => focusWindow ( windowId ) }
123+ focusSecond = { false }
115124 />
116125 )
117126 }
0 commit comments