diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2020-06-16 08:45:10 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2020-06-16 08:45:10 -0400 |
commit | ec8b9aef9ef0ce0e4bbe268524b1c185b3074f1a (patch) | |
tree | 319a75df2bf0679f26ed24c9cccd0560f460b1eb /src/fields/Doc.ts | |
parent | 23d91c839bc7dd14fd906aa1b3c7b3cd16980dd4 (diff) | |
parent | 157e80d5ee76f1c2386e2cde69fcc13188d27d8b (diff) |
Merge branch 'master' into RichTextEdition
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r-- | src/fields/Doc.ts | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 6f712f2ed..70aa2d60b 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -100,7 +100,7 @@ export const UpdatingFromServer = Symbol("UpdatingFromServer"); const CachedUpdates = Symbol("Cached updates"); -function fetchProto(doc: Doc) { +export function fetchProto(doc: Doc) { if (doc.author !== Doc.CurrentUserEmail) { const acl = Doc.Get(doc, "ACL", true); switch (acl) { @@ -116,21 +116,9 @@ function fetchProto(doc: Doc) { } } - const proto = doc.proto; - if (proto instanceof Promise) { - proto.then(proto => { - if (proto.author !== Doc.CurrentUserEmail) { - if (proto.ACL === "ownerOnly") { - proto[AclSym] = doc[AclSym] = AclPrivate; - return undefined; - } else if (proto.ACL === "readOnly") { - proto[AclSym] = doc[AclSym] = AclReadonly; - } else if (proto.ACL === "addOnly") { - proto[AclSym] = doc[AclSym] = AclAddonly; - } - } - }); - return proto; + if (doc.proto instanceof Promise) { + doc.proto.then(fetchProto); + return doc.proto; } } @@ -442,7 +430,8 @@ export namespace Doc { if (allowDuplicates !== true) { const pind = list.reduce((l, d, i) => d instanceof Doc && d[Id] === doc[Id] ? i : l, -1); if (pind !== -1) { - list.splice(pind, 1); + return true; + //list.splice(pind, 1); // bcz: this causes schemaView docs in the Catalog to move to the bottom of the schema view when they are dragged even though they haven't left the collection } } if (first) { @@ -690,7 +679,7 @@ export namespace Doc { } } }); - copy["author"] = Doc.CurrentUserEmail; + copy.author = Doc.CurrentUserEmail; return copy; } @@ -822,7 +811,7 @@ export namespace Doc { export function UserDoc(): Doc { return manager._user_doc; } export function SetSelectedTool(tool: InkTool) { Doc.UserDoc().activeInkTool = tool; } - export function GetSelectedTool(): InkTool { return (FieldValue(StrCast(Doc.UserDoc().activeInkTool)) ?? InkTool.None) as InkTool; } + export function GetSelectedTool(): InkTool { return StrCast(Doc.UserDoc().activeInkTool, InkTool.None) as InkTool; } export function SetUserDoc(doc: Doc) { manager._user_doc = doc; } export function IsBrushed(doc: Doc) { return computedFn(function IsBrushed(doc: Doc) { |