aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/Doc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r--src/new_fields/Doc.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index ba01cfd9c..87e048140 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -148,7 +148,7 @@ export class Doc extends RefField {
return "invalid";
}
- private [CachedUpdates]: { [key: string]: () => Promise<any> } = {};
+ private [CachedUpdates]: { [key: string]: () => void | Promise<any> } = {};
public async [HandleUpdate](diff: any) {
const set = diff.$set;
@@ -178,7 +178,7 @@ export class Doc extends RefField {
continue;
}
const fKey = key.substring(7);
- const fn = async () => {
+ const fn = () => {
updatingFromServer = true;
delete this[fKey];
updatingFromServer = false;
@@ -211,6 +211,14 @@ export namespace Doc {
delete doc[CachedUpdates][field];
}
}
+ export function AddCachedUpdate(doc: Doc, field: string, oldValue: any) {
+ const val = oldValue;
+ doc[CachedUpdates][field] = () => {
+ updatingFromServer = true;
+ doc[field] = val;
+ updatingFromServer = false;
+ };
+ }
export function MakeReadOnly(): { end(): void } {
makeReadOnly();
return {