Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
better behavior on default loading detail / switching between tree and detail
azivner32220476aa67
diff --git a/src/public/javascripts/mobile.js b/src/public/javascripts/mobile.jsindex 119ac5ab04..b529c64d70 100644--- a/src/public/javascripts/mobile.js+++ b/src/public/javascripts/mobile.js@@ -21,9 +21,19 @@ function togglePanes() {}}-$closeDetailButton.click(togglePanes);+function showDetailPane() {+ if (!$detail.is(":visible")) {+ $detail.removeClass("d-none");+ $leftPane.addClass("d-none");+ }+}++$closeDetailButton.click(() => {+ // no page is opened+ document.location.hash = '-';-let firstLoad = true;+ togglePanes();+});async function showTree() {const tree = await treeService.loadTree();@@ -42,12 +52,7 @@ async function showTree() {treeService.setCurrentNotePathToHash(node);- if (!firstLoad) {- togglePanes();- }- else {- firstLoad = false;- }+ showDetailPane();noteDetailService.switchToNote(noteId, true);},@@ -115,4 +120,9 @@ $("#log-out-button").click(() => {$("#logout-form").submit();});+// this is done so that startNotePath is not used+if (!document.location.hash) {+ document.location.hash = '-';+}+showTree();\ No newline at end of filediff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.jsindex bd593dcc35..7edbdb5295 100644--- a/src/public/javascripts/services/tree.js+++ b/src/public/javascripts/services/tree.js@@ -337,6 +337,10 @@ function clearSelectedNodes() {}async function treeInitialized() {+ if (startNotePath === '-') {+ return;+ }+const noteId = treeUtils.getNoteIdFromNotePath(startNotePath);if (!await treeCache.getNote(noteId)) {@@ -344,6 +348,7 @@ async function treeInitialized() {startNotePath = null;}+ // - is used in mobile to indicate that we don't want to activate any note after loadif (startNotePath) {const node = await activateNote(startNotePath);@@ -652,7 +657,7 @@ utils.bindShortcut('ctrl+.', scrollToCurrentNote);$(window).bind('hashchange', function() {const notePath = getNotePathFromAddress();- if (getCurrentNotePath() !== notePath) {+ if (notePath !== '-' && getCurrentNotePath() !== notePath) {console.debug("Switching to " + notePath + " because of hash change");activateNote(notePath);