mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51: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) { |     handleEventInChildren(name, data) { | ||||||
|         // stop propagation of the event to the children, individual tab widget should not know about tab switching
 |         if (['tabNoteSwitched', 'tabNoteSwitchedAndActivated'].includes(name)) { | ||||||
|         // since they are per-tab
 |  | ||||||
|         if (name === 'tabNoteSwitchedAndActivated') { |  | ||||||
|             name = 'tabNoteSwitched'; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (name === 'tabNoteSwitched') { |  | ||||||
|             // this event is propagated only to the widgets of a particular tab
 |             // this event is propagated only to the widgets of a particular tab
 | ||||||
|             const widget = this.widgets[data.tabContext.tabId]; |             const widget = this.widgets[data.tabContext.tabId]; | ||||||
| 
 | 
 | ||||||
|             if (widget) { |             if (widget && (widget.hasBeenAlreadyShown || name === 'tabNoteSwitchedAndActivated')) { | ||||||
|                 return widget.handleEvent(name, data); |                 return widget.handleEvent('tabNoteSwitched', data); | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 return Promise.resolve(); |                 return Promise.resolve(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (name !== 'activeTabChanged') { |         if (name === 'activeTabChanged') { | ||||||
|             return super.handleEventInChildren(name, data); |             const widget = this.widgets[data.tabContext.tabId]; | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|  |             if (widget.hasBeenAlreadyShown) { | ||||||
|                 return Promise.resolve(); |                 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