mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	date notes respect their parent's isProtected status, #1483
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| import utils from "./utils.js"; | ||||
| import dateNoteService from "./date_notes.js"; | ||||
| import hoistedNoteService from "./hoisted_note.js"; | ||||
| import protectedSessionHolder from './protected_session_holder.js'; | ||||
| import server from "./server.js"; | ||||
| import appContext from "./app_context.js"; | ||||
| import Component from "../widgets/component.js"; | ||||
| @@ -69,7 +69,7 @@ export default class Entrypoints extends Component { | ||||
|             title: 'new note', | ||||
|             content: '', | ||||
|             type: 'text', | ||||
|             isProtected: inboxNote.isProtected | ||||
|             isProtected: inboxNote.isProtected && protectedSessionHolder.isProtectedSessionAvailable() | ||||
|         }); | ||||
|  | ||||
|         await ws.waitForMaxKnownEntityChangeId(); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ const attributeService = require('./attributes'); | ||||
| const dateUtils = require('./date_utils'); | ||||
| const repository = require('./repository'); | ||||
| const sql = require('./sql'); | ||||
| const protectedSessionService = require('./protected_session'); | ||||
|  | ||||
| const CALENDAR_ROOT_LABEL = 'calendarRoot'; | ||||
| const YEAR_LABEL = 'yearNote'; | ||||
| @@ -14,14 +15,14 @@ const DATE_LABEL = 'dateNote'; | ||||
| const DAYS = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; | ||||
| const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December']; | ||||
|  | ||||
| function createNote(parentNoteId, noteTitle) { | ||||
|     return (noteService.createNewNote({ | ||||
|         parentNoteId: parentNoteId, | ||||
| function createNote(parentNote, noteTitle) { | ||||
|     return noteService.createNewNote({ | ||||
|         parentNoteId: parentNote.noteId, | ||||
|         title: noteTitle, | ||||
|         content: '', | ||||
|         isProtected: false, | ||||
|         isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(), | ||||
|         type: 'text' | ||||
|     })).note; | ||||
|     }).note; | ||||
| } | ||||
|  | ||||
| function getNoteStartingWith(parentNoteId, startsWith) { | ||||
| @@ -70,7 +71,7 @@ function getYearNote(dateStr, rootNote) { | ||||
|  | ||||
|         if (!yearNote) { | ||||
|             sql.transactional(() => { | ||||
|                 yearNote = createNote(rootNote.noteId, yearStr); | ||||
|                 yearNote = createNote(rootNote, yearStr); | ||||
|  | ||||
|                 attributeService.createLabel(yearNote.noteId, YEAR_LABEL, yearStr); | ||||
|                 attributeService.createLabel(yearNote.noteId, 'sorted'); | ||||
| @@ -118,7 +119,7 @@ function getMonthNote(dateStr, rootNote) { | ||||
|             const noteTitle = getMonthNoteTitle(rootNote, monthNumber, dateObj); | ||||
|  | ||||
|             sql.transactional(() => { | ||||
|                 monthNote = createNote(yearNote.noteId, noteTitle); | ||||
|                 monthNote = createNote(yearNote, noteTitle); | ||||
|  | ||||
|                 attributeService.createLabel(monthNote.noteId, MONTH_LABEL, monthStr); | ||||
|                 attributeService.createLabel(monthNote.noteId, 'sorted'); | ||||
| @@ -166,7 +167,7 @@ function getDateNote(dateStr) { | ||||
|             const noteTitle = getDateNoteTitle(rootNote, dayNumber, dateObj); | ||||
|  | ||||
|             sql.transactional(() => { | ||||
|                 dateNote = createNote(monthNote.noteId, noteTitle); | ||||
|                 dateNote = createNote(monthNote, noteTitle); | ||||
|  | ||||
|                 attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr.substr(0, 10)); | ||||
|  | ||||
|   | ||||
| @@ -121,7 +121,7 @@ function exportToZip(taskContext, branch, format, res) { | ||||
|             type: note.type, | ||||
|             mime: note.mime, | ||||
|             // we don't export utcDateCreated and utcDateModified of any entity since that would be a bit misleading | ||||
|             attributes: (note.getOwnedAttributes()).map(attribute => ({ | ||||
|             attributes: note.getOwnedAttributes().map(attribute => ({ | ||||
|                     type: attribute.type, | ||||
|                     name: attribute.name, | ||||
|                     value: attribute.value, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user