Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): rename readOnlyDecision

Elian Dorana2a509d45c0b
diff --git a/apps/client/src/components/note_context.ts b/apps/client/src/components/note_context.ts
index 9630756aef..11d32cf0db 100644
--- a/apps/client/src/components/note_context.ts
+++ b/apps/client/src/components/note_context.ts
@@ -275,13 +275,12 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded">
this.resetViewScope();
}
- // We've ensured viewScope exists by calling resetViewScope() if needed
- const viewScope = this.viewScope as ViewScope;
+ const viewScope = this.viewScope!;
- if (viewScope.readOnlyDecision === undefined) {
+ if (viewScope.isReadOnly === undefined) {
const blob = await this.note.getBlob();
if (!blob) {
- viewScope.readOnlyDecision = false;
+ viewScope.isReadOnly = false;
return false;
}
@@ -289,13 +288,13 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded">
? options.getInt("autoReadonlySizeText")
: options.getInt("autoReadonlySizeCode");
- viewScope.readOnlyDecision = Boolean(sizeLimit &&
+ viewScope.isReadOnly = Boolean(sizeLimit &&
blob.contentLength > sizeLimit &&
!this.note.isLabelTruthy("autoReadOnlyDisabled"));
}
// Return the cached decision, which won't change until viewScope is reset
- return viewScope.readOnlyDecision || false;
+ return viewScope.isReadOnly || false;
}
async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts
index e57aab6e23..9a6b60d68b 100644
--- a/apps/client/src/services/link.ts
+++ b/apps/client/src/services/link.ts
@@ -48,7 +48,13 @@ export interface ViewScope {
viewMode?: ViewMode;
attachmentId?: string;
readOnlyTemporarilyDisabled?: boolean;
- readOnlyDecision?: boolean;
+ /**
+ * If true, it indicates that the note in the view should be opened in read-only mode (for supported note types such as text or code).
+ *
+ * The reason why we store this information here is that a note can become read-only as the user types content in it, and we wouldn't want
+ * to immediately enter read-only mode.
+ */
+ isReadOnly?: boolean;
highlightsListPreviousVisible?: boolean;
highlightsListTemporarilyHidden?: boolean;
tocTemporarilyHidden?: boolean;