mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	same note in different tabs are synced
This commit is contained in:
		
							parent
							
								
									48b4488a58
								
							
						
					
					
						commit
						32fae5e9e8
					
				@ -41,14 +41,20 @@ async function reload() {
 | 
			
		||||
    await loadNoteDetail(getActiveTabContext().notePath);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function reloadAllTabs() {
 | 
			
		||||
    for (const tabContext of tabContexts) {
 | 
			
		||||
async function reloadTab(tabContext) {
 | 
			
		||||
    if (tabContext.note) {
 | 
			
		||||
        const note = await loadNote(tabContext.note.noteId);
 | 
			
		||||
 | 
			
		||||
        await loadNoteDetailToContext(tabContext, note, tabContext.notePath);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function reloadAllTabs() {
 | 
			
		||||
    for (const tabContext of tabContexts) {
 | 
			
		||||
        await reloadTab(tabContext);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function openInTab(notePath) {
 | 
			
		||||
    await loadNoteDetail(notePath, { newTab: true });
 | 
			
		||||
}
 | 
			
		||||
@ -289,6 +295,14 @@ async function noteDeleted(noteId) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function refreshTabs(sourceTabId, noteId) {
 | 
			
		||||
    for (const tc of tabContexts) {
 | 
			
		||||
        if (tc.noteId === noteId && tc.tabId !== sourceTabId) {
 | 
			
		||||
            await reloadTab(tc);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function focusOnTitle() {
 | 
			
		||||
    getActiveTabContext().$noteTitle.focus();
 | 
			
		||||
}
 | 
			
		||||
@ -322,10 +336,10 @@ function fireDetailLoaded() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
messagingService.subscribeToSyncMessages(syncData => {
 | 
			
		||||
    if (syncData.some(sync => sync.entityName === 'notes' && sync.entityId === getActiveNoteId())) {
 | 
			
		||||
    if (syncData.some(sync => sync.entityName === 'notes')) {
 | 
			
		||||
        infoService.showMessage('Reloading note because of background changes');
 | 
			
		||||
 | 
			
		||||
        reload();
 | 
			
		||||
        refreshTabs(null, sync.entityId);
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -505,5 +519,6 @@ export default {
 | 
			
		||||
    clearOpenTabsTask,
 | 
			
		||||
    filterTabs,
 | 
			
		||||
    openEmptyTab,
 | 
			
		||||
    noteDeleted
 | 
			
		||||
    noteDeleted,
 | 
			
		||||
    refreshTabs
 | 
			
		||||
};
 | 
			
		||||
@ -221,6 +221,8 @@ class TabContext {
 | 
			
		||||
    async saveNoteIfChanged() {
 | 
			
		||||
        if (this.isNoteChanged) {
 | 
			
		||||
            await this.saveNote();
 | 
			
		||||
 | 
			
		||||
            noteDetailService.refreshTabs(this.tabId, this.noteId);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user