Rename
This commit is contained in:
parent
3501394de5
commit
5edf8f37a6
1 changed files with 27 additions and 27 deletions
|
|
@ -20,13 +20,13 @@ export class SyncClient {
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/max-params
|
// eslint-disable-next-line @typescript-eslint/max-params
|
||||||
private constructor(
|
private constructor(
|
||||||
private readonly _history: SyncHistory,
|
private readonly history: SyncHistory,
|
||||||
private readonly _settings: Settings,
|
private readonly settings: Settings,
|
||||||
private readonly _database: Database,
|
private readonly database: Database,
|
||||||
private readonly _syncer: Syncer,
|
private readonly syncer: Syncer,
|
||||||
private readonly _syncService: SyncService,
|
private readonly syncService: SyncService,
|
||||||
private readonly _logger: Logger,
|
private readonly _logger: Logger,
|
||||||
private readonly _connectionStatus: ConnectionStatus
|
private readonly connectionStatus: ConnectionStatus
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public get logger(): Logger {
|
public get logger(): Logger {
|
||||||
|
|
@ -34,7 +34,7 @@ export class SyncClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public get documentCount(): number {
|
public get documentCount(): number {
|
||||||
return this._database.length;
|
return this.database.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async create({
|
public static async create({
|
||||||
|
|
@ -114,21 +114,21 @@ export class SyncClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async checkConnection(): Promise<CheckConnectionResult> {
|
public async checkConnection(): Promise<CheckConnectionResult> {
|
||||||
return this._syncService.checkConnection();
|
return this.syncService.checkConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHistoryEntries(): HistoryEntry[] {
|
public getHistoryEntries(): HistoryEntry[] {
|
||||||
return this._history.getEntries();
|
return this.history.getEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
public addSyncHistoryUpdateListener(
|
public addSyncHistoryUpdateListener(
|
||||||
listener: (stats: HistoryStats) => void
|
listener: (stats: HistoryStats) => void
|
||||||
): void {
|
): void {
|
||||||
this._history.addSyncHistoryUpdateListener(listener);
|
this.history.addSyncHistoryUpdateListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async start(): Promise<void> {
|
public async start(): Promise<void> {
|
||||||
this._settings.addOnSettingsChangeListener(
|
this.settings.addOnSettingsChangeListener(
|
||||||
(newSettings, oldSettings) => {
|
(newSettings, oldSettings) => {
|
||||||
if (
|
if (
|
||||||
newSettings.fetchChangesUpdateIntervalMs !==
|
newSettings.fetchChangesUpdateIntervalMs !==
|
||||||
|
|
@ -149,10 +149,10 @@ export class SyncClient {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
await this._syncer.scheduleSyncForOfflineChanges();
|
await this.syncer.scheduleSyncForOfflineChanges();
|
||||||
|
|
||||||
this.setRemoteEventListener(
|
this.setRemoteEventListener(
|
||||||
this._settings.getSettings().fetchChangesUpdateIntervalMs
|
this.settings.getSettings().fetchChangesUpdateIntervalMs
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,8 +162,8 @@ export class SyncClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async waitAndStop(): Promise<void> {
|
public async waitAndStop(): Promise<void> {
|
||||||
await this._syncer.waitForSyncQueue();
|
await this.syncer.waitForSyncQueue();
|
||||||
await this._syncer.applyRemoteChangesLocally();
|
await this.syncer.applyRemoteChangesLocally();
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,47 +172,47 @@ export class SyncClient {
|
||||||
/// The SyncClient can be used again after calling this method.
|
/// The SyncClient can be used again after calling this method.
|
||||||
public async reset(): Promise<void> {
|
public async reset(): Promise<void> {
|
||||||
this.stop();
|
this.stop();
|
||||||
this._connectionStatus.reset();
|
this.connectionStatus.reset();
|
||||||
await this._syncer.reset();
|
await this.syncer.reset();
|
||||||
this._history.reset();
|
this.history.reset();
|
||||||
this._database.reset();
|
this.database.reset();
|
||||||
this._logger.reset();
|
this._logger.reset();
|
||||||
void this.start();
|
void this.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSettings(): SyncSettings {
|
public getSettings(): SyncSettings {
|
||||||
return this._settings.getSettings();
|
return this.settings.getSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setSetting<T extends keyof SyncSettings>(
|
public async setSetting<T extends keyof SyncSettings>(
|
||||||
key: T,
|
key: T,
|
||||||
value: SyncSettings[T]
|
value: SyncSettings[T]
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await this._settings.setSetting(key, value);
|
await this.settings.setSetting(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public addOnSettingsChangeListener(
|
public addOnSettingsChangeListener(
|
||||||
handler: (settings: SyncSettings, oldSettings: SyncSettings) => void
|
handler: (settings: SyncSettings, oldSettings: SyncSettings) => void
|
||||||
): void {
|
): void {
|
||||||
this._settings.addOnSettingsChangeListener(handler);
|
this.settings.addOnSettingsChangeListener(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public addRemainingSyncOperationsListener(
|
public addRemainingSyncOperationsListener(
|
||||||
listener: (remainingOperations: number) => void
|
listener: (remainingOperations: number) => void
|
||||||
): void {
|
): void {
|
||||||
this._syncer.addRemainingOperationsListener(listener);
|
this.syncer.addRemainingOperationsListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async syncLocallyCreatedFile(
|
public async syncLocallyCreatedFile(
|
||||||
relativePath: RelativePath
|
relativePath: RelativePath
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this._syncer.syncLocallyCreatedFile(relativePath);
|
return this.syncer.syncLocallyCreatedFile(relativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async syncLocallyDeletedFile(
|
public async syncLocallyDeletedFile(
|
||||||
relativePath: RelativePath
|
relativePath: RelativePath
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return this._syncer.syncLocallyDeletedFile(relativePath);
|
return this.syncer.syncLocallyDeletedFile(relativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async syncLocallyUpdatedFile({
|
public async syncLocallyUpdatedFile({
|
||||||
|
|
@ -222,7 +222,7 @@ export class SyncClient {
|
||||||
oldPath?: RelativePath;
|
oldPath?: RelativePath;
|
||||||
relativePath: RelativePath;
|
relativePath: RelativePath;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this._syncer.syncLocallyUpdatedFile({
|
return this.syncer.syncLocallyUpdatedFile({
|
||||||
oldPath,
|
oldPath,
|
||||||
relativePath
|
relativePath
|
||||||
});
|
});
|
||||||
|
|
@ -234,7 +234,7 @@ export class SyncClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.remoteListenerIntervalId = setInterval(
|
this.remoteListenerIntervalId = setInterval(
|
||||||
() => void this._syncer.applyRemoteChangesLocally(),
|
() => void this.syncer.applyRemoteChangesLocally(),
|
||||||
intervalMs
|
intervalMs
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue