aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Doc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r--src/fields/Doc.ts21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 19ffc5005..df49c32f0 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -239,6 +239,19 @@ export class Doc extends RefField {
public static get MyFileOrphans() {
return DocCast(Doc.UserDoc().myFileOrphans);
}
+ public static AddFileOrphan(doc: Doc) {
+ if (
+ doc &&
+ Doc.MyFileOrphans instanceof Doc &&
+ Doc.IsPrototype(doc) &&
+ !Doc.IsSystem(doc) &&
+ ![DocumentType.MARKER, DocumentType.KVP, DocumentType.LINK, DocumentType.LINKANCHOR].includes(doc.type as any) &&
+ !doc.isFolder &&
+ !doc.annotationOn
+ ) {
+ Doc.AddDocToList(Doc.MyFileOrphans, undefined, doc);
+ }
+ }
public static get MyTools() {
return DocCast(Doc.UserDoc().myTools);
}
@@ -774,7 +787,7 @@ export namespace Doc {
}
cloneMap.set(doc[Id], copy);
}
- Doc.IsPrototype(copy) && Doc.AddDocToList(Doc.MyFileOrphans, undefined, copy);
+ Doc.AddFileOrphan(copy);
return copy;
}
export async function MakeClone(doc: Doc, dontCreate: boolean = false, asBranch = false, cloneMap: Map<string, Doc> = new Map()) {
@@ -958,7 +971,7 @@ export namespace Doc {
Object.keys(doc).forEach(key => {
if (exclude.includes(key)) return;
const cfield = ComputedField.WithoutComputed(() => FieldValue(doc[key]));
- const field = ProxyField.WithoutProxy(() => doc[key]);
+ const field = key === 'author' ? Doc.CurrentUserEmail : ProxyField.WithoutProxy(() => doc[key]);
if (key === 'proto' && copyProto) {
if (doc[key] instanceof Doc) {
copy[key] = Doc.MakeCopy(doc[key]!, false);
@@ -982,7 +995,6 @@ export namespace Doc {
}
}
});
- copy.author = Doc.CurrentUserEmail;
if (copyProto) {
Doc.GetProto(copy).context = undefined;
Doc.GetProto(copy).aliases = new List<Doc>([copy]);
@@ -994,7 +1006,7 @@ export namespace Doc {
if (retitle) {
copy.title = incrementTitleCopy(StrCast(copy.title));
}
- Doc.IsPrototype(copy) && Doc.AddDocToList(Doc.MyFileOrphans, undefined, copy);
+ Doc.AddFileOrphan(copy);
return copy;
}
@@ -1013,6 +1025,7 @@ export namespace Doc {
if (!Doc.IsSystem(doc)) Doc.AddDocToList(doc[DataSym], 'aliases', delegate);
title && (delegate.title = title);
delegate[Initializing] = false;
+ Doc.AddFileOrphan(delegate);
return delegate;
}
return undefined;