Skip to content

Commit ead325a

Browse files
author
Akos Kitta
committed
debounced the connectivity status update
do not run it on every incomming request but before timeout expires. Signed-off-by: Akos Kitta <[email protected]>
1 parent 93dc4d8 commit ead325a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: arduino-ide-extension/src/browser/theia/core/connection-status-service.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { ArduinoDaemon } from '../../../common/protocol';
1414
import { NotificationCenter } from '../../notification-center';
1515
import { nls } from '@theia/core/lib/common';
16+
import debounce = require('lodash.debounce');
1617

1718
@injectable()
1819
export class FrontendConnectionStatusService extends TheiaFrontendConnectionStatusService {
@@ -36,10 +37,11 @@ export class FrontendConnectionStatusService extends TheiaFrontendConnectionStat
3637
this.notificationCenter.onDaemonDidStop(
3738
() => (this.connectedPort = undefined)
3839
);
39-
this.wsConnectionProvider.onIncomingMessageActivity(() => {
40+
const refresh = debounce(() => {
4041
this.updateStatus(!!this.connectedPort);
4142
this.schedulePing();
42-
});
43+
}, this.options.offlineTimeout - 10);
44+
this.wsConnectionProvider.onIncomingMessageActivity(() => refresh());
4345
}
4446
}
4547

0 commit comments

Comments
 (0)