From 923316e14e344b0dadc4735cd5b4ca20c8f3a0de Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Wed, 21 May 2025 17:24:00 +0200 Subject: [PATCH] feat(client): handle read-only database --- apps/client/src/components/note_context.ts | 4 ++++ apps/client/src/widgets/floating_buttons/edit_button.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/apps/client/src/components/note_context.ts b/apps/client/src/components/note_context.ts index dd2391b67..c958512c6 100644 --- a/apps/client/src/components/note_context.ts +++ b/apps/client/src/components/note_context.ts @@ -254,6 +254,10 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded"> return false; } + if (options.is("databaseReadonly")) { + return true; + } + if (this.note.isLabelTruthy("readOnly")) { return true; } diff --git a/apps/client/src/widgets/floating_buttons/edit_button.ts b/apps/client/src/widgets/floating_buttons/edit_button.ts index 2a11f0d01..344447f31 100644 --- a/apps/client/src/widgets/floating_buttons/edit_button.ts +++ b/apps/client/src/widgets/floating_buttons/edit_button.ts @@ -6,6 +6,7 @@ import { t } from "../../services/i18n.js"; import LoadResults from "../../services/load_results.js"; import type { AttributeRow } from "../../services/load_results.js"; import FNote from "../../entities/fnote.js"; +import options from "../../services/options.js"; export default class EditButton extends OnClickButtonWidget { isEnabled(): boolean { @@ -27,6 +28,10 @@ export default class EditButton extends OnClickButtonWidget { } async refreshWithNote(note: FNote): Promise { + if (options.is("databaseReadonly")) { + this.toggleInt(false); + return; + } if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) { this.toggleInt(false); } else {