Migrate to private class properties/methods
This commit is contained in:
parent
7dbe57084b
commit
aa9f53df57
100 changed files with 3795 additions and 3944 deletions
|
@ -15,9 +15,8 @@ import type { ConfigType } from './base_config';
|
|||
* process.
|
||||
*/
|
||||
export class SystemTraySettingCache {
|
||||
private cachedValue: undefined | SystemTraySetting;
|
||||
|
||||
private getPromise: undefined | Promise<SystemTraySetting>;
|
||||
#cachedValue: undefined | SystemTraySetting;
|
||||
#getPromise: undefined | Promise<SystemTraySetting>;
|
||||
|
||||
constructor(
|
||||
private readonly ephemeralConfig: Pick<ConfigType, 'get' | 'set'>,
|
||||
|
@ -25,19 +24,19 @@ export class SystemTraySettingCache {
|
|||
) {}
|
||||
|
||||
async get(): Promise<SystemTraySetting> {
|
||||
if (this.cachedValue !== undefined) {
|
||||
return this.cachedValue;
|
||||
if (this.#cachedValue !== undefined) {
|
||||
return this.#cachedValue;
|
||||
}
|
||||
|
||||
this.getPromise = this.getPromise || this.doFirstGet();
|
||||
return this.getPromise;
|
||||
this.#getPromise = this.#getPromise || this.#doFirstGet();
|
||||
return this.#getPromise;
|
||||
}
|
||||
|
||||
set(value: SystemTraySetting): void {
|
||||
this.cachedValue = value;
|
||||
this.#cachedValue = value;
|
||||
}
|
||||
|
||||
private async doFirstGet(): Promise<SystemTraySetting> {
|
||||
async #doFirstGet(): Promise<SystemTraySetting> {
|
||||
let result: SystemTraySetting;
|
||||
|
||||
// These command line flags are not officially supported, but many users rely on them.
|
||||
|
@ -76,15 +75,15 @@ export class SystemTraySettingCache {
|
|||
);
|
||||
}
|
||||
|
||||
return this.updateCachedValue(result);
|
||||
return this.#updateCachedValue(result);
|
||||
}
|
||||
|
||||
private updateCachedValue(value: SystemTraySetting): SystemTraySetting {
|
||||
#updateCachedValue(value: SystemTraySetting): SystemTraySetting {
|
||||
// If there's a value in the cache, someone has updated the value "out from under us",
|
||||
// so we should return that because it's newer.
|
||||
this.cachedValue =
|
||||
this.cachedValue === undefined ? value : this.cachedValue;
|
||||
this.#cachedValue =
|
||||
this.#cachedValue === undefined ? value : this.#cachedValue;
|
||||
|
||||
return this.cachedValue;
|
||||
return this.#cachedValue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue