Extract settings from database
This commit is contained in:
parent
aef5952c4d
commit
614e4a780a
20 changed files with 344 additions and 319 deletions
|
|
@ -1,15 +1,15 @@
|
|||
import type { Client } from "openapi-fetch";
|
||||
import createClient from "openapi-fetch";
|
||||
import type { components, paths } from "./types"; // Generated by openapi-typescript
|
||||
import type { Database } from "../database/database";
|
||||
import type { SyncSettings } from "../database/sync-settings";
|
||||
import type {
|
||||
DocumentId,
|
||||
RelativePath,
|
||||
VaultUpdateId
|
||||
} from "src/database/document-metadata";
|
||||
} from "../persistence/database";
|
||||
import { Logger } from "src/tracing/logger";
|
||||
import { retriedFetch } from "src/utils/retried-fetch";
|
||||
import type { SyncSettings } from "dist/types";
|
||||
import type { Settings } from "src/persistence/settings";
|
||||
|
||||
export interface CheckConnectionResult {
|
||||
isSuccessful: boolean;
|
||||
|
|
@ -19,10 +19,10 @@ export class SyncService {
|
|||
private client: Client<paths>;
|
||||
private clientWithoutRetries: Client<paths>;
|
||||
|
||||
public constructor(private readonly database: Database) {
|
||||
this.createClient(database.getSettings());
|
||||
public constructor(private readonly settings: Settings) {
|
||||
this.createClient(settings.getSettings());
|
||||
|
||||
database.addOnSettingsChangeHandlers((s) => {
|
||||
settings.addOnSettingsChangeHandlers((s) => {
|
||||
this.createClient(s);
|
||||
});
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ export class SyncService {
|
|||
const response = await this.clientWithoutRetries.GET("/ping", {
|
||||
params: {
|
||||
header: {
|
||||
authorization: `Bearer ${this.database.getSettings().token}`
|
||||
authorization: `Bearer ${this.settings.getSettings().token}`
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -80,10 +80,10 @@ export class SyncService {
|
|||
{
|
||||
params: {
|
||||
path: {
|
||||
vault_id: this.database.getSettings().vaultName
|
||||
vault_id: this.settings.getSettings().vaultName
|
||||
},
|
||||
header: {
|
||||
authorization: `Bearer ${this.database.getSettings().token}`
|
||||
authorization: `Bearer ${this.settings.getSettings().token}`
|
||||
}
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
|
|
@ -130,11 +130,11 @@ export class SyncService {
|
|||
{
|
||||
params: {
|
||||
path: {
|
||||
vault_id: this.database.getSettings().vaultName,
|
||||
vault_id: this.settings.getSettings().vaultName,
|
||||
document_id: documentId
|
||||
},
|
||||
header: {
|
||||
authorization: `Bearer ${this.database.getSettings().token}`
|
||||
authorization: `Bearer ${this.settings.getSettings().token}`
|
||||
}
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
|
|
@ -171,11 +171,11 @@ export class SyncService {
|
|||
{
|
||||
params: {
|
||||
path: {
|
||||
vault_id: this.database.getSettings().vaultName,
|
||||
vault_id: this.settings.getSettings().vaultName,
|
||||
document_id: documentId
|
||||
},
|
||||
header: {
|
||||
authorization: `Bearer ${this.database.getSettings().token}`
|
||||
authorization: `Bearer ${this.settings.getSettings().token}`
|
||||
}
|
||||
},
|
||||
body: {
|
||||
|
|
@ -206,11 +206,11 @@ export class SyncService {
|
|||
{
|
||||
params: {
|
||||
path: {
|
||||
vault_id: this.database.getSettings().vaultName,
|
||||
vault_id: this.settings.getSettings().vaultName,
|
||||
document_id: documentId
|
||||
},
|
||||
header: {
|
||||
authorization: `Bearer ${this.database.getSettings().token}`
|
||||
authorization: `Bearer ${this.settings.getSettings().token}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -235,10 +235,10 @@ export class SyncService {
|
|||
const response = await this.client.GET("/vaults/{vault_id}/documents", {
|
||||
params: {
|
||||
path: {
|
||||
vault_id: this.database.getSettings().vaultName
|
||||
vault_id: this.settings.getSettings().vaultName
|
||||
},
|
||||
header: {
|
||||
authorization: `Bearer ${this.database.getSettings().token}`
|
||||
authorization: `Bearer ${this.settings.getSettings().token}`
|
||||
},
|
||||
query: {
|
||||
since_update_id: since
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue