Skip to content

Commit ee5e219

Browse files
committed
Remove public getter and use hoisted variable
1 parent 69a1318 commit ee5e219

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/model.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { ISignal, Signal } from '@phosphor/signaling';
88
import { httpGitRequest } from './git';
99
import { IGitExtension, Git } from './tokens';
1010

11+
// Refresh interval (note: this should be the same as in the plugin settings schema):
12+
let REFRESH_INTERVAL = 3000; // ms
13+
1114
/** Main extension class */
1215
export class GitExtension implements IGitExtension, IDisposable {
1316
constructor(app: JupyterFrontEnd = null) {
@@ -26,7 +29,7 @@ export class GitExtension implements IGitExtension, IDisposable {
2629
this._poll = new Poll({
2730
factory: () => this._refreshStatus(),
2831
frequency: {
29-
interval: this._refreshInterval,
32+
interval: REFRESH_INTERVAL,
3033
backoff: true,
3134
max: 300 * 1000
3235
},
@@ -36,19 +39,19 @@ export class GitExtension implements IGitExtension, IDisposable {
3639

3740
/**
3841
* Number of milliseconds between polling the file system for changes.
42+
*
43+
* ## Notes
44+
*
45+
* - WARNING: this should only be set upon changes to plugin settings. If the refresh interval is set independently of plugin settings (e.g., programmatically set by internal extension logic irrespective of whether plugin settings have changed), we run the risk of being out-of-sync with user expectation.
3946
*/
40-
public get refreshInterval(): number {
41-
return this._refreshInterval;
42-
}
43-
44-
public set refreshInterval(v: number) {
47+
set refreshInterval(v: number) {
4548
const freq = this._poll.frequency;
4649
this._poll.frequency = {
4750
interval: v,
4851
backoff: freq.backoff,
4952
max: freq.max
5053
};
51-
this._refreshInterval = v;
54+
REFRESH_INTERVAL = v;
5255
}
5356

5457
/**
@@ -924,7 +927,6 @@ export class GitExtension implements IGitExtension, IDisposable {
924927
private _readyPromise: Promise<void> = Promise.resolve();
925928
private _pendingReadyPromise = 0;
926929
private _poll: Poll;
927-
private _refreshInterval = 3000; // ms
928930
private _headChanged = new Signal<IGitExtension, void>(this);
929931
private _markChanged = new Signal<IGitExtension, void>(this);
930932
private _repositoryChanged = new Signal<

0 commit comments

Comments
 (0)