mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-01-06 04:50:03 -06:00
sharing WIP
This commit is contained in:
@@ -11,6 +11,12 @@ const becca = require("../becca/becca");
|
||||
const beccaService = require("../becca/becca_service");
|
||||
|
||||
function cloneNoteToParent(noteId, parentBranchId, prefix) {
|
||||
if (parentBranchId === 'share') {
|
||||
const specialNotesService = require('./special_notes');
|
||||
// share root note is created lazily
|
||||
specialNotesService.getShareRoot();
|
||||
}
|
||||
|
||||
const parentBranch = becca.getBranch(parentBranchId);
|
||||
|
||||
if (isNoteDeleted(noteId) || isNoteDeleted(parentBranch.noteId)) {
|
||||
|
||||
@@ -118,6 +118,7 @@ function createNewNote(params) {
|
||||
note.setContent(params.content);
|
||||
|
||||
const branch = new Branch({
|
||||
branchId: params.branchId,
|
||||
noteId: note.noteId,
|
||||
parentNoteId: params.parentNoteId,
|
||||
notePosition: params.notePosition !== undefined ? params.notePosition : getNewNotePosition(params.parentNoteId),
|
||||
@@ -540,7 +541,7 @@ function deleteBranch(branch, deleteId, taskContext) {
|
||||
branch.markAsDeleted(deleteId);
|
||||
|
||||
const note = branch.getNote();
|
||||
const notDeletedBranches = note.getBranches();
|
||||
const notDeletedBranches = note.getParentBranches();
|
||||
|
||||
if (notDeletedBranches.length === 0) {
|
||||
for (const childBranch of note.getChildBranches()) {
|
||||
@@ -785,7 +786,7 @@ function duplicateSubtree(origNoteId, newParentNoteId) {
|
||||
|
||||
const origNote = becca.notes[origNoteId];
|
||||
// might be null if orig note is not in the target newParentNoteId
|
||||
const origBranch = origNote.getBranches().find(branch => branch.parentNoteId === newParentNoteId);
|
||||
const origBranch = origNote.getParentBranches().find(branch => branch.parentNoteId === newParentNoteId);
|
||||
|
||||
const noteIdMapping = getNoteIdMapping(origNote);
|
||||
|
||||
|
||||
@@ -206,11 +206,12 @@ function getShareRoot() {
|
||||
|
||||
if (!shareRoot) {
|
||||
shareRoot = noteService.createNewNote({
|
||||
branchId: 'share',
|
||||
noteId: 'share',
|
||||
title: 'share',
|
||||
title: 'Shared notes',
|
||||
type: 'text',
|
||||
content: '',
|
||||
parentNoteId: getHiddenRoot().noteId
|
||||
parentNoteId: 'root'
|
||||
}).note;
|
||||
}
|
||||
|
||||
@@ -223,7 +224,7 @@ function createMissingSpecialNotes() {
|
||||
getSinglesNoteRoot();
|
||||
getSinglesNoteRoot();
|
||||
getGlobalNoteMap();
|
||||
getShareRoot();
|
||||
// share root is not automatically created since it's visible in the tree and many won't need it/use it
|
||||
|
||||
const hidden = getHiddenRoot();
|
||||
|
||||
@@ -238,5 +239,6 @@ module.exports = {
|
||||
saveSqlConsole,
|
||||
createSearchNote,
|
||||
saveSearchNote,
|
||||
createMissingSpecialNotes
|
||||
createMissingSpecialNotes,
|
||||
getShareRoot
|
||||
};
|
||||
|
||||
@@ -173,7 +173,7 @@ function sortNotes(parentNoteId, customSortBy = 'title', reverse = false, folder
|
||||
let position = 10;
|
||||
|
||||
for (const note of notes) {
|
||||
const branch = note.getBranches().find(b => b.parentNoteId === parentNoteId);
|
||||
const branch = note.getParentBranches().find(b => b.parentNoteId === parentNoteId);
|
||||
|
||||
sql.execute("UPDATE branches SET notePosition = ? WHERE branchId = ?",
|
||||
[position, branch.branchId]);
|
||||
|
||||
Reference in New Issue
Block a user