mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	when closing / clearing last tab, close all splits
This commit is contained in:
		
							parent
							
								
									0a4f419e5e
								
							
						
					
					
						commit
						15a9ff4450
					
				@ -306,7 +306,8 @@ export default class TabManager extends Component {
 | 
				
			|||||||
                const mainNoteContexts = this.getNoteContexts().filter(nc => nc.isMainContext());
 | 
					                const mainNoteContexts = this.getNoteContexts().filter(nc => nc.isMainContext());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (mainNoteContexts.length === 1) {
 | 
					                if (mainNoteContexts.length === 1) {
 | 
				
			||||||
                    mainNoteContexts[0].setEmpty();
 | 
					                    await this.clearLastMainNoteContext(noteContextToRemove);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -317,7 +318,7 @@ export default class TabManager extends Component {
 | 
				
			|||||||
            const noteContextsToRemove = noteContextToRemove.getSubContexts();
 | 
					            const noteContextsToRemove = noteContextToRemove.getSubContexts();
 | 
				
			||||||
            const ntxIdsToRemove = noteContextsToRemove.map(nc => nc.ntxId);
 | 
					            const ntxIdsToRemove = noteContextsToRemove.map(nc => nc.ntxId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await this.triggerEvent('beforeTabRemove', { ntxIds: ntxIdsToRemove });
 | 
					            await this.triggerEvent('beforeNoteContextRemove', { ntxIds: ntxIdsToRemove });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!noteContextToRemove.isMainContext()) {
 | 
					            if (!noteContextToRemove.isMainContext()) {
 | 
				
			||||||
                await this.activateNoteContext(noteContextToRemove.getMainContext().ntxId);
 | 
					                await this.activateNoteContext(noteContextToRemove.getMainContext().ntxId);
 | 
				
			||||||
@ -336,6 +337,30 @@ export default class TabManager extends Component {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            this.removeNoteContexts(noteContextsToRemove);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    async clearLastMainNoteContext(noteContextToClear) {
 | 
				
			||||||
 | 
					        noteContextToClear.setEmpty();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // activate main split
 | 
				
			||||||
 | 
					        await this.activateNoteContext(noteContextToClear.ntxId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // remove all other splits
 | 
				
			||||||
 | 
					        const noteContextsToRemove = noteContextToClear.getSubContexts()
 | 
				
			||||||
 | 
					            .filter(ntx => ntx.ntxId !== noteContextToClear.ntxId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const ntxIdsToRemove = noteContextsToRemove.map(ntx => ntx.ntxId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        await this.triggerEvent('beforeNoteContextRemove', {ntxIds: ntxIdsToRemove});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.removeNoteContexts(noteContextsToRemove);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    removeNoteContexts(noteContextsToRemove) {
 | 
				
			||||||
 | 
					        const ntxIdsToRemove = noteContextsToRemove.map(nc => nc.ntxId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.children = this.children.filter(nc => !ntxIdsToRemove.includes(nc.ntxId));
 | 
					        this.children = this.children.filter(nc => !ntxIdsToRemove.includes(nc.ntxId));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.recentlyClosedTabs.push(noteContextsToRemove);
 | 
					        this.recentlyClosedTabs.push(noteContextsToRemove);
 | 
				
			||||||
@ -343,7 +368,6 @@ export default class TabManager extends Component {
 | 
				
			|||||||
        this.triggerEvent('noteContextRemoved', {ntxIds: ntxIdsToRemove});
 | 
					        this.triggerEvent('noteContextRemoved', {ntxIds: ntxIdsToRemove});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.tabsUpdate.scheduleUpdate();
 | 
					        this.tabsUpdate.scheduleUpdate();
 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tabReorderEvent({ntxIdsInOrder}) {
 | 
					    tabReorderEvent({ntxIdsInOrder}) {
 | 
				
			||||||
 | 
				
			|||||||
@ -216,7 +216,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async beforeTabRemoveEvent({ntxIds}) {
 | 
					    async beforeNoteContextRemoveEvent({ntxIds}) {
 | 
				
			||||||
        if (this.isNoteContext(ntxIds)) {
 | 
					        if (this.isNoteContext(ntxIds)) {
 | 
				
			||||||
            await this.spacedUpdate.updateNowIfNecessary();
 | 
					            await this.spacedUpdate.updateNowIfNecessary();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -87,7 +87,7 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async beforeTabRemoveEvent({ntxIds}) {
 | 
					    async beforeNoteContextRemoveEvent({ntxIds}) {
 | 
				
			||||||
        if (this.isNoteContext(ntxIds)) {
 | 
					        if (this.isNoteContext(ntxIds)) {
 | 
				
			||||||
            await this.spacedUpdate.updateNowIfNecessary();
 | 
					            await this.spacedUpdate.updateNowIfNecessary();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user