mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	improve hiding of edit button #2787
This commit is contained in:
		
							parent
							
								
									f705c432fd
								
							
						
					
					
						commit
						6b61b0604a
					
				| @ -1,5 +1,7 @@ | |||||||
| import ButtonWidget from "./button_widget.js"; | import ButtonWidget from "./button_widget.js"; | ||||||
| import appContext from "../../services/app_context.js"; | import appContext from "../../services/app_context.js"; | ||||||
|  | import attributeService from "../../services/attributes.js"; | ||||||
|  | import protectedSessionHolder from "../../services/protected_session_holder.js"; | ||||||
| 
 | 
 | ||||||
| export default class EditButton extends ButtonWidget { | export default class EditButton extends ButtonWidget { | ||||||
|     isEnabled() { |     isEnabled() { | ||||||
| @ -22,9 +24,29 @@ export default class EditButton extends ButtonWidget { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async refreshWithNote(note) { |     async refreshWithNote(note) { | ||||||
|  |         if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) { | ||||||
|  |             this.toggleInt(false); | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             // prevent flickering by assuming hidden before async operation
 | ||||||
|  |             this.toggleInt(false); | ||||||
|  | 
 | ||||||
|             // can't do this in isEnabled() since isReadOnly is async
 |             // can't do this in isEnabled() since isReadOnly is async
 | ||||||
|             this.toggleInt(await this.noteContext.isReadOnly()); |             this.toggleInt(await this.noteContext.isReadOnly()); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         await super.refreshWithNote(note); |         await super.refreshWithNote(note); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     entitiesReloadedEvent({loadResults}) { | ||||||
|  |         if (loadResults.getAttributes().find( | ||||||
|  |             attr => attr.type === 'label' | ||||||
|  |                 && attr.name.toLowerCase().includes("readonly") | ||||||
|  |                 && attributeService.isAffecting(attr, this.note) | ||||||
|  |         )) { | ||||||
|  |             this.noteContext.readOnlyTemporarilyDisabled = false; | ||||||
|  | 
 | ||||||
|  |             this.refresh(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam