fix #clipperInbox, closes #4153

This commit is contained in:
zadam 2023-08-09 23:00:42 +02:00
parent a9cdd93cb4
commit 1d869d25c2
2 changed files with 6 additions and 6 deletions

View File

@ -17,21 +17,20 @@ const jsdom = require("jsdom");
const { JSDOM } = jsdom; const { JSDOM } = jsdom;
function addClipping(req) { function addClipping(req) {
// if a note under the clipperInbox as the same 'pageUrl' attribute, // if a note under the clipperInbox has the same 'pageUrl' attribute,
// add the content to that note and clone it under today's inbox // add the content to that note and clone it under today's inbox
// otherwise just create a new note under today's inbox // otherwise just create a new note under today's inbox
let {title, content, pageUrl, images} = req.body; let {title, content, pageUrl, images} = req.body;
const clipType = 'clippings'; const clipType = 'clippings';
const clipperInbox = getClipperInboxNote(); const clipperInbox = getClipperInboxNote();
const dailyNote = dateNoteService.getDayNote(dateUtils.localNowDate());
pageUrl = htmlSanitizer.sanitizeUrl(pageUrl); pageUrl = htmlSanitizer.sanitizeUrl(pageUrl);
let clippingNote = findClippingNote(clipperInbox, pageUrl, clipType); let clippingNote = findClippingNote(clipperInbox, pageUrl, clipType);
if (!clippingNote) { if (!clippingNote) {
clippingNote = noteService.createNewNote({ clippingNote = noteService.createNewNote({
parentNoteId: dailyNote.noteId, parentNoteId: clipperInbox.noteId,
title: title, title: title,
content: '', content: '',
type: 'text' type: 'text'
@ -48,8 +47,8 @@ function addClipping(req) {
clippingNote.setContent(`${existingContent}${existingContent.trim() ? "<br>" : ""}${rewrittenContent}`); clippingNote.setContent(`${existingContent}${existingContent.trim() ? "<br>" : ""}${rewrittenContent}`);
if (clippingNote.parentNoteId !== dailyNote.noteId) { if (clippingNote.parentNoteId !== clipperInbox.noteId) {
cloneService.cloneNoteToParentNote(clippingNote.noteId, dailyNote.noteId); cloneService.cloneNoteToParentNote(clippingNote.noteId, clipperInbox.noteId);
} }
return { return {
@ -79,7 +78,7 @@ function getClipperInboxNote() {
let clipperInbox = attributeService.getNoteWithLabel('clipperInbox'); let clipperInbox = attributeService.getNoteWithLabel('clipperInbox');
if (!clipperInbox) { if (!clipperInbox) {
clipperInbox = dateNoteService.getRootCalendarNote(); clipperInbox = dateNoteService.getDayNote(dateUtils.localNowDate());
} }
return clipperInbox; return clipperInbox;

View File

@ -65,6 +65,7 @@ module.exports = [
{ type: 'label', name: 'executeButton'}, { type: 'label', name: 'executeButton'},
{ type: 'label', name: 'executeDescription'}, { type: 'label', name: 'executeDescription'},
{ type: 'label', name: 'newNotesOnTop'}, { type: 'label', name: 'newNotesOnTop'},
{ type: 'label', name: 'clipperInbox'},
// relation names // relation names
{ type: 'relation', name: 'internalLink' }, { type: 'relation', name: 'internalLink' },