Skip to content

Commit a1dd5a2

Browse files
committed
laying foundations for trust (doesn't impact anything yet)
1 parent f461880 commit a1dd5a2

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

src/packages/frontend/frame-editors/code-editor/actions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3043,4 +3043,12 @@ export class Actions<
30433043
.getIn(["editor_settings", "build_on_save"]);
30443044
set_account_table({ editor_settings: { build_on_save: !val } });
30453045
}
3046+
3047+
getTrust = () => {
3048+
return this._syncstring.get_settings()?.get("trust");
3049+
};
3050+
3051+
setTrust = async (trust: boolean) => {
3052+
await this._syncstring.set_settings({ trust });
3053+
};
30463054
}

src/packages/frontend/frame-editors/frame-tree/frame-context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import { Map } from "immutable";
1515
import { createContext, useContext } from "react";
16-
1716
import { useRedux } from "@cocalc/frontend/app-framework/redux-hooks";
1817
import { DEFAULT_FONT_SIZE } from "@cocalc/util/db-schema/defaults";
1918
import { Actions } from "../code-editor/actions";

src/packages/sync/editor/generic/sync-doc.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,9 +2342,12 @@ export class SyncDoc extends EventEmitter {
23422342
};
23432343

23442344
public set_snapshot_interval = async (n: number): Promise<void> => {
2345-
this.syncstring_table.set(
2346-
this.syncstring_table_get_one().set("snapshot_interval", n),
2347-
);
2345+
this.syncstring_table.set({
2346+
string_id: this.string_id,
2347+
project_id: this.project_id,
2348+
path: this.path,
2349+
snapshot_interval: n,
2350+
});
23482351
await this.syncstring_table.save();
23492352
};
23502353

@@ -2721,7 +2724,7 @@ export class SyncDoc extends EventEmitter {
27212724
return size;
27222725
};
27232726

2724-
private set_save = async (x: {
2727+
private set_save = async (save: {
27252728
state: string;
27262729
error: string;
27272730
hash?: number;
@@ -2731,18 +2734,23 @@ export class SyncDoc extends EventEmitter {
27312734
this.assert_table_is_ready("syncstring");
27322735
// set timestamp of when the save happened; this can be useful
27332736
// for coordinating running code, etc.... and is just generally useful.
2734-
x.time = Date.now();
2735-
this.syncstring_table.set(
2736-
this.syncstring_table_get_one().set("save", fromJS(x)),
2737-
);
2737+
this.syncstring_table.set({
2738+
string_id: this.string_id,
2739+
project_id: this.project_id,
2740+
path: this.path,
2741+
save,
2742+
});
27382743
await this.syncstring_table.save();
27392744
};
27402745

27412746
private set_read_only = async (read_only: boolean): Promise<void> => {
27422747
this.assert_table_is_ready("syncstring");
2743-
this.syncstring_table.set(
2744-
this.syncstring_table_get_one().set("read_only", read_only),
2745-
);
2748+
this.syncstring_table.set({
2749+
string_id: this.string_id,
2750+
project_id: this.project_id,
2751+
path: this.path,
2752+
read_only,
2753+
});
27462754
await this.syncstring_table.save();
27472755
};
27482756

0 commit comments

Comments
 (0)