create new sortNotes backend API method and deprecate old sortNotesByTitle

This commit is contained in:
zadam
2022-12-25 13:01:50 +01:00
parent 7c98ade72b
commit bd59802ca4
25 changed files with 480 additions and 97 deletions

View File

@@ -30,7 +30,6 @@
const Note = require('./note');
const AbstractEntity = require("./abstract_entity");
const sql = require("../../services/sql");
const dateUtils = require("../../services/date_utils");
const utils = require("../../services/utils");
const TaskContext = require("../../services/task_context");
@@ -41,6 +40,9 @@ const log = require("../../services/log");
* Branch represents a relationship between a child note and its parent note. Trilium allows a note to have multiple
* parents.
*
* Note that you should not rely on the branch's identity, since it can change easily with a note's move.
* Always check noteId instead.
*
* @extends AbstractEntity
*/
class Branch extends AbstractEntity {
@@ -157,7 +159,7 @@ class Branch extends AbstractEntity {
* @returns {boolean}
*/
get isWeak() {
return ['_share', 'lbBookmarks'].includes(this.parentNoteId);
return ['_share', '_lbBookmarks'].includes(this.parentNoteId);
}
/**
@@ -239,7 +241,7 @@ class Branch extends AbstractEntity {
let maxNotePos = 0;
for (const childBranch of this.parentNote.getChildBranches()) {
if (maxNotePos < childBranch.notePosition && childBranch.branchId !== '_hidden') {
if (maxNotePos < childBranch.notePosition && childBranch.noteId !== '_hidden') {
maxNotePos = childBranch.notePosition;
}
}
@@ -293,7 +295,7 @@ module.exports = Branch;
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-sql.html">sql</a></li></ul><h3>Classes</h3><ul><li><a href="AbstractEntity.html">AbstractEntity</a></li><li><a href="Attribute.html">Attribute</a></li><li><a href="BackendScriptApi.html">BackendScriptApi</a></li><li><a href="Branch.html">Branch</a></li><li><a href="EtapiToken.html">EtapiToken</a></li><li><a href="Note.html">Note</a></li><li><a href="NoteRevision.html">NoteRevision</a></li><li><a href="Option.html">Option</a></li><li><a href="RecentNote.html">RecentNote</a></li></ul><h3><a href="global.html">Global</a></h3>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-sql.html">sql</a></li></ul><h3>Classes</h3><ul><li><a href="AbstractEntity.html">AbstractEntity</a></li><li><a href="Attribute.html">Attribute</a></li><li><a href="BackendScriptApi.html">BackendScriptApi</a></li><li><a href="Branch.html">Branch</a></li><li><a href="EtapiToken.html">EtapiToken</a></li><li><a href="Note.html">Note</a></li><li><a href="NoteRevision.html">NoteRevision</a></li><li><a href="Option.html">Option</a></li><li><a href="RecentNote.html">RecentNote</a></li></ul><h3>Global</h3><ul><li><a href="global.html#SortConfig">SortConfig</a></li></ul>
</nav>
<br class="clear">