feat(config): show / hide info on load
This commit is contained in:
parent
ce16a9d999
commit
dbc7e8c2f9
@ -9,9 +9,12 @@ backend:
|
||||
whiteboardInfoBroadcastFreq: 1
|
||||
|
||||
frontend:
|
||||
# When an editable whiteboard is loading in a client,
|
||||
# should it be started in read-only mode.
|
||||
readOnlyOnWhiteboardLoad: false
|
||||
# When a whiteboard is loading in a client
|
||||
onWhiteboardLoad:
|
||||
# should an (editable) whiteboard be started in read-only mode by default
|
||||
setReadOnly: false
|
||||
# should the whiteboard info be displayed by default
|
||||
displayInfo: false
|
||||
# Show smallest screen indicator
|
||||
showSmallestScreenIndicator: true
|
||||
performance:
|
||||
|
@ -30,10 +30,20 @@
|
||||
"frontend": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["readOnlyOnWhiteboardLoad", "showSmallestScreenIndicator", "performance"],
|
||||
"required": ["onWhiteboardLoad", "showSmallestScreenIndicator", "performance"],
|
||||
"properties": {
|
||||
"readOnlyOnWhiteboardLoad": {
|
||||
"type": "boolean"
|
||||
"onWhiteboardLoad": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["displayInfo", "setReadOnly"],
|
||||
"properties": {
|
||||
"setReadOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"displayInfo": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"showSmallestScreenIndicator": {
|
||||
"type": "boolean"
|
||||
|
@ -31,11 +31,11 @@ test("Complex object config override", () => {
|
||||
|
||||
test("Override default config", () => {
|
||||
const defaultConfig = getDefaultConfig();
|
||||
const overrideConfig1 = { frontend: { readOnlyOnWhiteboardLoad: true } };
|
||||
const overrideConfig1 = { frontend: { onWhiteboardLoad: { setReadOnly: true } } };
|
||||
|
||||
expect(deepMergeConfigs(defaultConfig, overrideConfig1).frontend.readOnlyOnWhiteboardLoad).toBe(
|
||||
true
|
||||
);
|
||||
expect(
|
||||
deepMergeConfigs(defaultConfig, overrideConfig1).frontend.onWhiteboardLoad.setReadOnly
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
test("Dumb config is not valid", () => {
|
||||
|
@ -603,10 +603,14 @@ function initWhiteboard() {
|
||||
// fix bug cursor not showing up
|
||||
whiteboard.refreshCursorAppearance();
|
||||
|
||||
if (process.env.NODE_ENV === "production" && ConfigService.readOnlyOnWhiteboardLoad) {
|
||||
ReadOnlyService.activateReadOnlyMode();
|
||||
InfoService.hideInfo();
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
if (ConfigService.readOnlyOnWhiteboardLoad) ReadOnlyService.activateReadOnlyMode();
|
||||
else ReadOnlyService.deactivateReadOnlyMode();
|
||||
|
||||
if (ConfigService.displayInfoOnWhiteboardLoad) InfoService.displayInfo();
|
||||
else InfoService.hideInfo();
|
||||
} else {
|
||||
// in dev
|
||||
ReadOnlyService.deactivateReadOnlyMode();
|
||||
InfoService.displayInfo();
|
||||
}
|
||||
|
@ -10,11 +10,15 @@ class ConfigService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @type {{displayInfo: boolean, setReadOnly: boolean}}
|
||||
* @readonly
|
||||
*/
|
||||
#readOnlyOnWhiteboardLoad = false;
|
||||
#onWhiteboardLoad = { setReadOnly: false, displayInfo: false };
|
||||
get readOnlyOnWhiteboardLoad() {
|
||||
return this.#readOnlyOnWhiteboardLoad;
|
||||
return this.#onWhiteboardLoad.setReadOnly;
|
||||
}
|
||||
get displayInfoOnWhiteboardLoad() {
|
||||
return this.#onWhiteboardLoad.displayInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,9 +54,9 @@ class ConfigService {
|
||||
this.#configFromServer = configFromServer;
|
||||
|
||||
const { common } = configFromServer;
|
||||
const { readOnlyOnWhiteboardLoad, showSmallestScreenIndicator, performance } = common;
|
||||
const { onWhiteboardLoad, showSmallestScreenIndicator, performance } = common;
|
||||
|
||||
this.#readOnlyOnWhiteboardLoad = readOnlyOnWhiteboardLoad;
|
||||
this.#onWhiteboardLoad = onWhiteboardLoad;
|
||||
this.#showSmallestScreenIndicator = showSmallestScreenIndicator;
|
||||
this.#refreshInfoInterval = 1000 / performance.refreshInfoFreq;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user