diff options
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r-- | src/fields/Doc.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 9dc3c173d..d726f7064 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -574,8 +574,10 @@ export namespace Doc { } export function BestEmbedding(doc: Doc) { - const bestEmbedding = Doc.GetProto(doc) ? [doc, ...DocListCast(doc.proto_embeddings)].find(doc => !doc.embedContainer && doc.author === Doc.CurrentUserEmail) : doc; - bestEmbedding && Doc.AddDocToList(Doc.GetProto(doc), 'protoEmbeddings', doc); + const dataDoc = doc[DocData]; + const availableEmbeddings = DocListCast(dataDoc.proto_embeddings); + const bestEmbedding = [...(dataDoc !== doc ? [doc] : []), ...availableEmbeddings].find(doc => !doc.embedContainer && doc.author === Doc.CurrentUserEmail); + bestEmbedding && Doc.AddDocToList(dataDoc, 'protoEmbeddings', doc); return bestEmbedding ?? Doc.MakeEmbedding(doc); } |