Migrate to private class properties/methods

This commit is contained in:
Jamie Kyle
2025-01-14 11:11:52 -08:00
committed by GitHub
parent 7dbe57084b
commit aa9f53df57
100 changed files with 3795 additions and 3944 deletions

View File

@@ -25,7 +25,7 @@ export type DownloadOptionsType = Readonly<{
}>;
export class BackupAPI {
private cachedBackupInfo = new Map<
#cachedBackupInfo = new Map<
BackupCredentialType,
GetBackupInfoResponseType
>();
@@ -38,23 +38,23 @@ export class BackupAPI {
this.credentials.getHeadersForToday(type)
)
);
await Promise.all(headers.map(h => this.server.refreshBackup(h)));
await Promise.all(headers.map(h => this.#server.refreshBackup(h)));
}
public async getInfo(
credentialType: BackupCredentialType
): Promise<GetBackupInfoResponseType> {
const backupInfo = await this.server.getBackupInfo(
const backupInfo = await this.#server.getBackupInfo(
await this.credentials.getHeadersForToday(credentialType)
);
this.cachedBackupInfo.set(credentialType, backupInfo);
this.#cachedBackupInfo.set(credentialType, backupInfo);
return backupInfo;
}
private async getCachedInfo(
async #getCachedInfo(
credentialType: BackupCredentialType
): Promise<GetBackupInfoResponseType> {
const cached = this.cachedBackupInfo.get(credentialType);
const cached = this.#cachedBackupInfo.get(credentialType);
if (cached) {
return cached;
}
@@ -63,15 +63,15 @@ export class BackupAPI {
}
public async getMediaDir(): Promise<string> {
return (await this.getCachedInfo(BackupCredentialType.Media)).mediaDir;
return (await this.#getCachedInfo(BackupCredentialType.Media)).mediaDir;
}
public async getBackupDir(): Promise<string> {
return (await this.getCachedInfo(BackupCredentialType.Media))?.backupDir;
return (await this.#getCachedInfo(BackupCredentialType.Media))?.backupDir;
}
public async upload(filePath: string, fileSize: number): Promise<void> {
const form = await this.server.getBackupUploadForm(
const form = await this.#server.getBackupUploadForm(
await this.credentials.getHeadersForToday(BackupCredentialType.Messages)
);
@@ -95,7 +95,7 @@ export class BackupAPI {
BackupCredentialType.Messages
);
return this.server.getBackupStream({
return this.#server.getBackupStream({
cdn,
backupDir,
backupName,
@@ -111,7 +111,7 @@ export class BackupAPI {
onProgress,
abortSignal,
}: DownloadOptionsType): Promise<Readable> {
const response = await this.server.getTransferArchive({
const response = await this.#server.getTransferArchive({
abortSignal,
});
@@ -128,7 +128,7 @@ export class BackupAPI {
const { cdn, key } = response;
return this.server.getEphemeralBackupStream({
return this.#server.getEphemeralBackupStream({
cdn,
key,
downloadOffset,
@@ -138,7 +138,7 @@ export class BackupAPI {
}
public async getMediaUploadForm(): Promise<AttachmentUploadFormResponseType> {
return this.server.getBackupMediaUploadForm(
return this.#server.getBackupMediaUploadForm(
await this.credentials.getHeadersForToday(BackupCredentialType.Media)
);
}
@@ -146,7 +146,7 @@ export class BackupAPI {
public async backupMediaBatch(
items: ReadonlyArray<BackupMediaItemType>
): Promise<BackupMediaBatchResponseType> {
return this.server.backupMediaBatch({
return this.#server.backupMediaBatch({
headers: await this.credentials.getHeadersForToday(
BackupCredentialType.Media
),
@@ -161,7 +161,7 @@ export class BackupAPI {
cursor?: string;
limit: number;
}): Promise<BackupListMediaResponseType> {
return this.server.backupListMedia({
return this.#server.backupListMedia({
headers: await this.credentials.getHeadersForToday(
BackupCredentialType.Media
),
@@ -171,10 +171,10 @@ export class BackupAPI {
}
public clearCache(): void {
this.cachedBackupInfo.clear();
this.#cachedBackupInfo.clear();
}
private get server(): WebAPIType {
get #server(): WebAPIType {
const { server } = window.textsecure;
strictAssert(server, 'server not available');