File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,16 +72,20 @@ application.connect('activate', () => {
7272 if ( installed ) {
7373 open . emit ( 'clicked' ) ;
7474 }
75- for ( const title of [ 'Get Gitify' , 'Set up AppIndicator' ] ) {
75+ await [ 'Get Gitify' , 'Set up AppIndicator' ] . reduce ( async ( promise , title ) => {
76+ await promise ;
7677 const link = all . find (
7778 ( widget ) => widget instanceof Gtk . Button && widget . tooltip_text === title ,
7879 ) ;
7980 assert ( link , `Missing link: ${ title } ` ) ;
8081 link . emit ( 'clicked' ) ;
8182 await delay ( 500 ) ;
82- }
83+ } , Promise . resolve ( ) ) ;
8384 const actionsPath = GLib . getenv ( 'GITIFY_PREFS_ACTIONS' ) ;
84- for ( let attempt = 0 ; attempt < 20 ; attempt ++ ) {
85+ const waitForActions = async ( attempt = 0 ) => {
86+ if ( attempt === 20 ) {
87+ throw new Error ( 'Expected app/browser launches did not reach the desktop handlers' ) ;
88+ }
8589 if ( GLib . file_test ( actionsPath , GLib . FileTest . EXISTS ) ) {
8690 const [ , bytes ] = GLib . file_get_contents ( actionsPath ) ;
8791 const actions = new TextDecoder ( ) . decode ( bytes ) ;
@@ -104,8 +108,9 @@ application.connect('activate', () => {
104108 }
105109 }
106110 await delay ( 100 ) ;
107- }
108- throw new Error ( 'Expected app/browser launches did not reach the desktop handlers' ) ;
111+ return waitForActions ( attempt + 1 ) ;
112+ } ;
113+ await waitForActions ( ) ;
109114 } ) ( ) . catch ( ( error ) => {
110115 failure = error ;
111116 application . quit ( ) ;
You can’t perform that action at this time.
0 commit comments