1
1
import * as React from 'react' ;
2
2
import debounce = require( 'lodash.debounce' ) ;
3
3
import { Event } from '@theia/core/lib/common/event' ;
4
+ import { CommandService } from '@theia/core/lib/common/command' ;
5
+ import { MessageService } from '@theia/core/lib/common/message-service' ;
6
+ import { OutputCommands } from '@theia/output/lib/browser/output-commands' ;
4
7
import { ConfirmDialog } from '@theia/core/lib/browser/dialogs' ;
5
8
import { Searchable } from '../../../common/protocol/searchable' ;
6
9
import { Installable } from '../../../common/protocol/installable' ;
@@ -85,9 +88,13 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
85
88
const dialog = new InstallationProgressDialog ( itemLabel ( item ) , version ) ;
86
89
try {
87
90
dialog . open ( ) ;
91
+ await this . clearArduinoChannel ( ) ;
88
92
await install ( { item, version } ) ;
89
93
const items = await searchable . search ( { query : this . state . filterText } ) ;
90
94
this . setState ( { items : this . sort ( items ) } ) ;
95
+ } catch ( error ) {
96
+ this . props . messageService . error ( error instanceof Error ? error . message : String ( error ) ) ;
97
+ throw error ;
91
98
} finally {
92
99
dialog . close ( ) ;
93
100
}
@@ -106,6 +113,7 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
106
113
const { uninstall, searchable, itemLabel } = this . props ;
107
114
const dialog = new UninstallationProgressDialog ( itemLabel ( item ) ) ;
108
115
try {
116
+ await this . clearArduinoChannel ( ) ;
109
117
dialog . open ( ) ;
110
118
await uninstall ( { item } ) ;
111
119
const items = await searchable . search ( { query : this . state . filterText } ) ;
@@ -115,6 +123,10 @@ export class FilterableListContainer<T extends ArduinoComponent> extends React.C
115
123
}
116
124
}
117
125
126
+ private async clearArduinoChannel ( ) : Promise < void > {
127
+ return this . props . commandService . executeCommand ( OutputCommands . CLEAR . id , { name : 'Arduino' } ) ;
128
+ }
129
+
118
130
}
119
131
120
132
export namespace FilterableListContainer {
@@ -129,6 +141,8 @@ export namespace FilterableListContainer {
129
141
readonly filterTextChangeEvent : Event < string | undefined > ;
130
142
readonly install : ( { item, version } : { item : T , version : Installable . Version } ) => Promise < void > ;
131
143
readonly uninstall : ( { item } : { item : T } ) => Promise < void > ;
144
+ readonly messageService : MessageService ;
145
+ readonly commandService : CommandService ;
132
146
}
133
147
134
148
export interface State < T > {
0 commit comments