From 70514195b3fa76e0f5087fd814b9ab06a51ca2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rge=20N=C3=A6ss?= Date: Wed, 30 Oct 2024 20:52:19 +0100 Subject: [PATCH] fix: fix issue with applyMutation not writing back to documentMap --- src/local/documentMap/applyMutations.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/local/documentMap/applyMutations.ts b/src/local/documentMap/applyMutations.ts index aa8d31c..78d70c0 100644 --- a/src/local/documentMap/applyMutations.ts +++ b/src/local/documentMap/applyMutations.ts @@ -1,4 +1,5 @@ import {type Mutation, type SanityDocumentBase} from '../../mutations/types' +import {type DocumentMap} from '../types' import {getMutationDocumentId} from '../utils/getMutationDocumentId' import {applyDocumentMutation} from './applyDocumentMutation' @@ -15,7 +16,7 @@ export interface UpdateResult { */ export function applyMutations( mutations: Mutation[], - documentMap: {get: (id: string) => T | undefined}, + documentMap: DocumentMap, ): UpdateResult[] { const updatedDocs: Record< string, @@ -48,6 +49,8 @@ export function applyMutations( if (!(documentId in updatedDocs)) { updatedDocs[documentId] = {before, after: undefined, muts: []} } + documentMap.set(documentId, res.after) + updatedDocs[documentId]!.after = res.after } }