From ab550a1e8dc33b05911fb84363f1a4baf99d2cae Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 7 Dec 2021 23:03:49 +0100 Subject: [PATCH] share functionality WIP --- package.json | 4 ++-- src/public/stylesheets/share.css | 9 ++++++--- src/services/special_notes.js | 17 +++++++++++++++++ src/share/shaca/shaca_loader.js | 17 +++++++++++++++-- src/share/share_root.js | 2 +- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 4a8cbbc9c..c18f44484 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "joplin-turndown-plugin-gfm": "1.0.12", "jsdom": "19.0.0", "mime-types": "2.1.34", - "multer": "1.4.3", + "multer": "1.4.4", "node-abi": "3.5.0", "normalize-strings": "^1.1.1", "open": "8.4.0", @@ -92,7 +92,7 @@ "jsdoc": "3.6.7", "lorem-ipsum": "2.0.4", "rcedit": "3.0.1", - "webpack": "5.64.4", + "webpack": "5.65.0", "webpack-cli": "4.9.1" }, "optionalDependencies": { diff --git a/src/public/stylesheets/share.css b/src/public/stylesheets/share.css index 8dfedce57..2a8de286c 100644 --- a/src/public/stylesheets/share.css +++ b/src/public/stylesheets/share.css @@ -9,7 +9,6 @@ padding: 20px; flex-basis: 0; flex-grow: 1; - background-color: #ccc; overflow: auto; } @@ -17,6 +16,11 @@ margin: 0; } +#menu > p { + font-weight: bold; + font-size: 110%; +} + #menu ul { padding-left: 20px; } @@ -24,12 +28,11 @@ #main { flex-basis: 0; flex-grow: 3; - background-color:#eee; } #title { margin: 0; - padding: 20px 20px 0 20px; + padding: 10px 20px 0 20px; } #content { diff --git a/src/services/special_notes.js b/src/services/special_notes.js index 9c27f7f14..bc6bcf541 100644 --- a/src/services/special_notes.js +++ b/src/services/special_notes.js @@ -201,12 +201,29 @@ function getHoistedNote() { return becca.getNote(cls.getHoistedNoteId()); } +function getShareRoot() { + let shareRoot = becca.getNote('share'); + + if (!shareRoot) { + shareRoot = noteService.createNewNote({ + noteId: 'share', + title: 'share', + type: 'text', + content: '', + parentNoteId: getHiddenRoot().noteId + }).note; + } + + return shareRoot; +} + function createMissingSpecialNotes() { getSinglesNoteRoot(); getSqlConsoleRoot(); getSinglesNoteRoot(); getSinglesNoteRoot(); getGlobalNoteMap(); + getShareRoot(); const hidden = getHiddenRoot(); diff --git a/src/share/shaca/shaca_loader.js b/src/share/shaca/shaca_loader.js index 0cc5819a1..84b21bd7b 100644 --- a/src/share/shaca/shaca_loader.js +++ b/src/share/shaca/shaca_loader.js @@ -7,6 +7,7 @@ const Note = require('./entities/note'); const Branch = require('./entities/branch'); const Attribute = require('./entities/attribute'); const shareRoot = require('../share_root'); +const eventService = require("../../services/events"); function load() { const start = Date.now(); @@ -41,8 +42,17 @@ function load() { new Branch(row); } - // TODO: add filter for allowed attributes - for (const row of sql.getRawRows(`SELECT attributeId, noteId, type, name, value, isInheritable, position, utcDateModified FROM attributes WHERE isDeleted = 0 AND noteId IN (${noteIdStr})`, [])) { + const attributes = sql.getRawRows(` + SELECT attributeId, noteId, type, name, value, isInheritable, position, utcDateModified + FROM attributes + WHERE isDeleted = 0 + AND noteId IN (${noteIdStr}) + AND ( + (type = 'label' AND name IN ('archived')) + OR (type = 'relation' AND name IN ('imageLink', 'template')) + )`, []); + + for (const row of attributes) { new Attribute(row); } @@ -57,6 +67,9 @@ function ensureLoad() { } } +eventService.subscribe([ eventService.ENTITY_CREATED, eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED, eventService.ENTITY_CHANGE_SYNCED, eventService.ENTITY_DELETE_SYNCED ], ({ entityName, entity }) => { + shaca.reset(); +}); module.exports = { load, diff --git a/src/share/share_root.js b/src/share/share_root.js index 712646572..73dbbab8b 100644 --- a/src/share/share_root.js +++ b/src/share/share_root.js @@ -1,3 +1,3 @@ module.exports = { - SHARE_ROOT_NOTE_ID: 'root' + SHARE_ROOT_NOTE_ID: 'share' }