mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	implement lazy loading of tabs which speeds up especially initial startup with many tabs
This commit is contained in:
		
							parent
							
								
									8526cb2315
								
							
						
					
					
						commit
						ff853c7d0a
					
				| @ -57,29 +57,37 @@ export default class TabCachingWidget extends TabAwareWidget { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * widget.hasBeenAlreadyShown is intended for lazy loading of cached tabs - initial note switches of new tabs | ||||
|      * are not executed, we're waiting for the first tab activation and then we update the tab. After this initial | ||||
|      * activation further note switches are always propagated to the tabs. | ||||
|      */ | ||||
|     handleEventInChildren(name, data) { | ||||
|         // stop propagation of the event to the children, individual tab widget should not know about tab switching
 | ||||
|         // since they are per-tab
 | ||||
|         if (name === 'tabNoteSwitchedAndActivated') { | ||||
|             name = 'tabNoteSwitched'; | ||||
|         } | ||||
| 
 | ||||
|         if (name === 'tabNoteSwitched') { | ||||
|         if (['tabNoteSwitched', 'tabNoteSwitchedAndActivated'].includes(name)) { | ||||
|             // this event is propagated only to the widgets of a particular tab
 | ||||
|             const widget = this.widgets[data.tabContext.tabId]; | ||||
| 
 | ||||
|             if (widget) { | ||||
|                 return widget.handleEvent(name, data); | ||||
|             if (widget && (widget.hasBeenAlreadyShown || name === 'tabNoteSwitchedAndActivated')) { | ||||
|                 return widget.handleEvent('tabNoteSwitched', data); | ||||
|             } | ||||
|             else { | ||||
|                 return Promise.resolve(); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (name !== 'activeTabChanged') { | ||||
|             return super.handleEventInChildren(name, data); | ||||
|         } | ||||
|         if (name === 'activeTabChanged') { | ||||
|             const widget = this.widgets[data.tabContext.tabId]; | ||||
| 
 | ||||
|             if (widget.hasBeenAlreadyShown) { | ||||
|                 return Promise.resolve(); | ||||
|             } | ||||
|             else { | ||||
|                 widget.hasBeenAlreadyShown = true; | ||||
| 
 | ||||
|                 return widget.handleEvent(name, data); | ||||
|             } | ||||
|         } else { | ||||
|             return super.handleEventInChildren(name, data); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam