mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
some refactoring etc.
This commit is contained in:
parent
be68391c37
commit
8a501521e8
File diff suppressed because one or more lines are too long
@ -1,6 +1,7 @@
|
|||||||
import optionsInit from './options_init.js';
|
import optionsInit from './options_init.js';
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import tree from "./tree.js";
|
import tree from "./tree.js";
|
||||||
|
import noteDetailService from "./note_detail.js";
|
||||||
|
|
||||||
let hoistedNoteId;
|
let hoistedNoteId;
|
||||||
|
|
||||||
@ -17,6 +18,10 @@ async function getHoistedNoteId() {
|
|||||||
async function setHoistedNoteId(noteId) {
|
async function setHoistedNoteId(noteId) {
|
||||||
hoistedNoteId = noteId;
|
hoistedNoteId = noteId;
|
||||||
|
|
||||||
|
if (noteId !== 'root') {
|
||||||
|
await noteDetailService.filterTabs(noteId);
|
||||||
|
}
|
||||||
|
|
||||||
await server.put('options/hoistedNoteId/' + noteId);
|
await server.put('options/hoistedNoteId/' + noteId);
|
||||||
|
|
||||||
await tree.reload();
|
await tree.reload();
|
||||||
|
@ -61,6 +61,8 @@ async function switchToNote(notePath) {
|
|||||||
await saveNotesIfChanged();
|
await saveNotesIfChanged();
|
||||||
|
|
||||||
await loadNoteDetail(notePath);
|
await loadNoteDetail(notePath);
|
||||||
|
|
||||||
|
openTabsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getActiveNoteContent() {
|
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 newTab = !!options.newTab;
|
||||||
const activate = !!options.activate;
|
const activate = !!options.activate;
|
||||||
|
|
||||||
@ -218,6 +220,19 @@ async function loadNote(noteId) {
|
|||||||
return new NoteFull(treeCache, row);
|
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() {
|
function focusOnTitle() {
|
||||||
getActiveContext().$noteTitle.focus();
|
getActiveContext().$noteTitle.focus();
|
||||||
}
|
}
|
||||||
@ -280,9 +295,17 @@ chromeTabsEl.addEventListener('activeTabChange', ({ detail }) => {
|
|||||||
console.log(`Activated tab ${tabId}`);
|
console.log(`Activated tab ${tabId}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
chromeTabsEl.addEventListener('tabRemove', ({ detail }) => {
|
chromeTabsEl.addEventListener('tabRemove', async ({ detail }) => {
|
||||||
const tabId = parseInt(detail.tabEl.getAttribute('data-tab-id'));
|
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);
|
tabContexts = tabContexts.filter(nc => nc.tabId !== tabId);
|
||||||
|
|
||||||
console.log(`Removed tab ${tabId}`);
|
console.log(`Removed tab ${tabId}`);
|
||||||
@ -399,5 +422,6 @@ export default {
|
|||||||
addDetailLoadedListener,
|
addDetailLoadedListener,
|
||||||
getActiveContext,
|
getActiveContext,
|
||||||
getActiveComponent,
|
getActiveComponent,
|
||||||
clearOpenTabsTask
|
clearOpenTabsTask,
|
||||||
|
filterTabs
|
||||||
};
|
};
|
@ -531,7 +531,9 @@ async function reload() {
|
|||||||
// make sure the reload won't trigger reactivation. This is important especially in cases where we wait for the reload
|
// make sure the reload won't trigger reactivation. This is important especially in cases where we wait for the reload
|
||||||
// to finish to then activate some other note. But since the activate() event is called asynchronously, it may be called
|
// to finish to then activate some other note. But since the activate() event is called asynchronously, it may be called
|
||||||
// (or finished calling) after we switched to a different note.
|
// (or finished calling) after we switched to a different note.
|
||||||
ignoreNextActivationNoteId = getActiveNode().data.noteId;
|
if (getActiveNode()) {
|
||||||
|
ignoreNextActivationNoteId = getActiveNode().data.noteId;
|
||||||
|
}
|
||||||
|
|
||||||
await getTree().reload(notes);
|
await getTree().reload(notes);
|
||||||
}
|
}
|
||||||
|
@ -743,7 +743,7 @@ div[data-notify="container"] {
|
|||||||
|
|
||||||
.unhoist-button {
|
.unhoist-button {
|
||||||
text-decoration: underline !important;
|
text-decoration: underline !important;
|
||||||
color: blue !important;
|
color: var(--link-color) !important;
|
||||||
cursor: pointer !important;
|
cursor: pointer !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user