From 562978eb6fe3a887d28230792553181cf7115ceb Mon Sep 17 00:00:00 2001 From: Ben Merckx Date: Tue, 14 Nov 2023 10:43:35 +0100 Subject: [PATCH] Sync with cloud changes --- src/backend/Handler.ts | 2 +- src/cloud/server/CloudHandler.ts | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/backend/Handler.ts b/src/backend/Handler.ts index bfd20fb08..93dbed993 100644 --- a/src/backend/Handler.ts +++ b/src/backend/Handler.ts @@ -146,7 +146,7 @@ class HandlerConnection implements Connection { const toApply = await pending.pendingSince(meta.commitHash, this.ctx) if (!toApply) return meta await db.applyMutations(toApply.mutations, toApply.toCommitHash) - return await db.meta() + return db.meta() } async syncRequired(contentHash: string): Promise { diff --git a/src/cloud/server/CloudHandler.ts b/src/cloud/server/CloudHandler.ts index ae0c49a81..0040a9cbb 100644 --- a/src/cloud/server/CloudHandler.ts +++ b/src/cloud/server/CloudHandler.ts @@ -46,6 +46,7 @@ export class CloudApi implements Media, Target, History, Pending, Drafts { constructor(private config: Config) {} mutate(params: Connection.MutateParams, ctx: Connection.Context) { + console.log(params) return fetch( cloudConfig.mutate, withAuth( @@ -160,7 +161,7 @@ export class CloudApi implements Media, Target, History, Pending, Drafts { withAuth( ctx, asJson({ - method: 'POST', + method: 'PUT', body: JSON.stringify(body) }) ) @@ -175,14 +176,20 @@ export class CloudApi implements Media, Target, History, Pending, Drafts { ): Promise { return fetch(cloudConfig.drafts + '/' + entryId, withAuth(ctx)) .then(failOnHttpError) - .then>(json) - .then>(Outcome.fromJSON) + .then>(json) + .then>( + Outcome.fromJSON + ) .then(Outcome.unpack) - .then(({fileHash, update}) => ({ - entryId, - fileHash, - draft: base64.parse(update) - })) + .then(data => { + return data + ? { + entryId, + fileHash: data.fileHash, + draft: base64.parse(data.update) + } + : undefined + }) } }