diff --git a/src/timer-db/TimerDB.ts b/src/timer-db/TimerDB.ts index d9378c3..43c778d 100644 --- a/src/timer-db/TimerDB.ts +++ b/src/timer-db/TimerDB.ts @@ -9,8 +9,8 @@ export class TimerDB { this.storage = new PouchDBStorage(); } - startSync(params: { username: string; password: string }): void { - this.storage.connectRemoteDB(params.username, params.password); + startSync(params: { username: string; password: string; options?: {dbURL: string} }): void { + this.storage.connectRemoteDB(params.username, params.password, params.options); } // TODO: provide a way to get only sessions with solves. diff --git a/src/timer-db/storage/PouchDBStorage.ts b/src/timer-db/storage/PouchDBStorage.ts index 2e8db34..fb92480 100644 --- a/src/timer-db/storage/PouchDBStorage.ts +++ b/src/timer-db/storage/PouchDBStorage.ts @@ -37,8 +37,8 @@ export class PouchDBStorage { // }); } - connectRemoteDB(username: string, password: string): void { - const url = new URL(DB_URL); + connectRemoteDB(username: string, password: string, options?: {dbURL: string} ): void { + const url = options === null ? new URL(DB_URL) : new URL(options.dbURL) url.username = username; url.password = password; url.pathname = `results-${localStorage.timerDBUsername}`; diff --git a/src/timer-db/storage/Storage.ts b/src/timer-db/storage/Storage.ts index 1dd8311..369751f 100644 --- a/src/timer-db/storage/Storage.ts +++ b/src/timer-db/storage/Storage.ts @@ -10,7 +10,7 @@ import { SessionUUID } from "../UUID"; export type SyncChangeListener = (attempt: StoredAttempt[]) => void; export declare interface Storage { - connectRemoteDB(username: string, password: string): void; + connectRemoteDB(username: string, password: string, options?: {dbURL: string} ): void; // Sessions createSession(