File tree 2 files changed +25
-5
lines changed
2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -261,14 +261,33 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded">
261
261
return true ;
262
262
}
263
263
264
- const blob = await this . note . getBlob ( ) ;
265
- if ( ! blob ) {
266
- return false ;
264
+ // Store the initial decision about read-only status in the viewScope
265
+ // This will be "remembered" until the viewScope is refreshed
266
+ if ( ! this . viewScope ) {
267
+ this . resetViewScope ( ) ;
267
268
}
268
269
269
- const sizeLimit = this . note . type === "text" ? options . getInt ( "autoReadonlySizeText" ) : options . getInt ( "autoReadonlySizeCode" ) ;
270
+ // We've ensured viewScope exists by calling resetViewScope() if needed
271
+ const viewScope = this . viewScope as ViewScope ;
272
+
273
+ if ( viewScope . readOnlyDecision === undefined ) {
274
+ const blob = await this . note . getBlob ( ) ;
275
+ if ( ! blob ) {
276
+ viewScope . readOnlyDecision = false ;
277
+ return false ;
278
+ }
279
+
280
+ const sizeLimit = this . note . type === "text"
281
+ ? options . getInt ( "autoReadonlySizeText" )
282
+ : options . getInt ( "autoReadonlySizeCode" ) ;
283
+
284
+ viewScope . readOnlyDecision = Boolean ( sizeLimit &&
285
+ blob . contentLength > sizeLimit &&
286
+ ! this . note . isLabelTruthy ( "autoReadOnlyDisabled" ) ) ;
287
+ }
270
288
271
- return sizeLimit && blob . contentLength > sizeLimit && ! this . note . isLabelTruthy ( "autoReadOnlyDisabled" ) ;
289
+ // Return the cached decision, which won't change until viewScope is reset
290
+ return viewScope . readOnlyDecision || false ;
272
291
}
273
292
274
293
async entitiesReloadedEvent ( { loadResults } : EventData < "entitiesReloaded" > ) {
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ export interface ViewScope {
48
48
viewMode ?: ViewMode ;
49
49
attachmentId ?: string ;
50
50
readOnlyTemporarilyDisabled ?: boolean ;
51
+ readOnlyDecision ?: boolean ;
51
52
highlightsListPreviousVisible ?: boolean ;
52
53
highlightsListTemporarilyHidden ?: boolean ;
53
54
tocTemporarilyHidden ?: boolean ;
You can’t perform that action at this time.
0 commit comments