mirror of
https://github.com/zadam/trilium.git
synced 2025-11-18 03:00:41 +01:00
some refactoring etc.
This commit is contained in:
@@ -61,6 +61,8 @@ async function switchToNote(notePath) {
|
||||
await saveNotesIfChanged();
|
||||
|
||||
await loadNoteDetail(notePath);
|
||||
|
||||
openTabsChanged();
|
||||
}
|
||||
|
||||
function getActiveNoteContent() {
|
||||
@@ -178,7 +180,7 @@ async function loadNoteDetailToContext(ctx, note, notePath) {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadNoteDetail(notePath, options) {
|
||||
async function loadNoteDetail(notePath, options = {}) {
|
||||
const newTab = !!options.newTab;
|
||||
const activate = !!options.activate;
|
||||
|
||||
@@ -218,6 +220,19 @@ async function loadNote(noteId) {
|
||||
return new NoteFull(treeCache, row);
|
||||
}
|
||||
|
||||
async function filterTabs(noteId) {
|
||||
for (const tc of tabContexts) {
|
||||
chromeTabs.removeTab(tc.tab);
|
||||
}
|
||||
|
||||
await loadNoteDetail(noteId, {
|
||||
newTab: true,
|
||||
activate: true
|
||||
});
|
||||
|
||||
await saveOpenTabs();
|
||||
}
|
||||
|
||||
function focusOnTitle() {
|
||||
getActiveContext().$noteTitle.focus();
|
||||
}
|
||||
@@ -280,9 +295,17 @@ chromeTabsEl.addEventListener('activeTabChange', ({ detail }) => {
|
||||
console.log(`Activated tab ${tabId}`);
|
||||
});
|
||||
|
||||
chromeTabsEl.addEventListener('tabRemove', ({ detail }) => {
|
||||
chromeTabsEl.addEventListener('tabRemove', async ({ detail }) => {
|
||||
const tabId = parseInt(detail.tabEl.getAttribute('data-tab-id'));
|
||||
|
||||
await saveNotesIfChanged();
|
||||
|
||||
const tabContentToDelete = tabContexts.find(nc => nc.tabId === tabId);
|
||||
|
||||
if (tabContentToDelete) {
|
||||
tabContentToDelete.$tabContent.remove();
|
||||
}
|
||||
|
||||
tabContexts = tabContexts.filter(nc => nc.tabId !== tabId);
|
||||
|
||||
console.log(`Removed tab ${tabId}`);
|
||||
@@ -399,5 +422,6 @@ export default {
|
||||
addDetailLoadedListener,
|
||||
getActiveContext,
|
||||
getActiveComponent,
|
||||
clearOpenTabsTask
|
||||
clearOpenTabsTask,
|
||||
filterTabs
|
||||
};
|
||||
Reference in New Issue
Block a user