mirror of
https://github.com/zadam/trilium.git
synced 2025-02-25 07:25:32 +08:00
better behavior on default loading detail / switching between tree and detail
This commit is contained in:
parent
86bc84a2ad
commit
32220476aa
2 changed files with 24 additions and 9 deletions
|
@ -21,9 +21,19 @@ function togglePanes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$closeDetailButton.click(togglePanes);
|
function showDetailPane() {
|
||||||
|
if (!$detail.is(":visible")) {
|
||||||
|
$detail.removeClass("d-none");
|
||||||
|
$leftPane.addClass("d-none");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let firstLoad = true;
|
$closeDetailButton.click(() => {
|
||||||
|
// no page is opened
|
||||||
|
document.location.hash = '-';
|
||||||
|
|
||||||
|
togglePanes();
|
||||||
|
});
|
||||||
|
|
||||||
async function showTree() {
|
async function showTree() {
|
||||||
const tree = await treeService.loadTree();
|
const tree = await treeService.loadTree();
|
||||||
|
@ -42,12 +52,7 @@ async function showTree() {
|
||||||
|
|
||||||
treeService.setCurrentNotePathToHash(node);
|
treeService.setCurrentNotePathToHash(node);
|
||||||
|
|
||||||
if (!firstLoad) {
|
showDetailPane();
|
||||||
togglePanes();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
firstLoad = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
noteDetailService.switchToNote(noteId, true);
|
noteDetailService.switchToNote(noteId, true);
|
||||||
},
|
},
|
||||||
|
@ -115,4 +120,9 @@ $("#log-out-button").click(() => {
|
||||||
$("#logout-form").submit();
|
$("#logout-form").submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// this is done so that startNotePath is not used
|
||||||
|
if (!document.location.hash) {
|
||||||
|
document.location.hash = '-';
|
||||||
|
}
|
||||||
|
|
||||||
showTree();
|
showTree();
|
|
@ -337,6 +337,10 @@ function clearSelectedNodes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function treeInitialized() {
|
async function treeInitialized() {
|
||||||
|
if (startNotePath === '-') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const noteId = treeUtils.getNoteIdFromNotePath(startNotePath);
|
const noteId = treeUtils.getNoteIdFromNotePath(startNotePath);
|
||||||
|
|
||||||
if (!await treeCache.getNote(noteId)) {
|
if (!await treeCache.getNote(noteId)) {
|
||||||
|
@ -344,6 +348,7 @@ async function treeInitialized() {
|
||||||
startNotePath = null;
|
startNotePath = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - is used in mobile to indicate that we don't want to activate any note after load
|
||||||
if (startNotePath) {
|
if (startNotePath) {
|
||||||
const node = await activateNote(startNotePath);
|
const node = await activateNote(startNotePath);
|
||||||
|
|
||||||
|
@ -652,7 +657,7 @@ utils.bindShortcut('ctrl+.', scrollToCurrentNote);
|
||||||
$(window).bind('hashchange', function() {
|
$(window).bind('hashchange', function() {
|
||||||
const notePath = getNotePathFromAddress();
|
const notePath = getNotePathFromAddress();
|
||||||
|
|
||||||
if (getCurrentNotePath() !== notePath) {
|
if (notePath !== '-' && getCurrentNotePath() !== notePath) {
|
||||||
console.debug("Switching to " + notePath + " because of hash change");
|
console.debug("Switching to " + notePath + " because of hash change");
|
||||||
|
|
||||||
activateNote(notePath);
|
activateNote(notePath);
|
||||||
|
|
Loading…
Reference in a new issue