share functionality WIP

This commit is contained in:
zadam 2021-12-07 23:03:49 +01:00
parent 08e8047d8a
commit ab550a1e8d
5 changed files with 41 additions and 8 deletions

View File

@ -58,7 +58,7 @@
"joplin-turndown-plugin-gfm": "1.0.12", "joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "19.0.0", "jsdom": "19.0.0",
"mime-types": "2.1.34", "mime-types": "2.1.34",
"multer": "1.4.3", "multer": "1.4.4",
"node-abi": "3.5.0", "node-abi": "3.5.0",
"normalize-strings": "^1.1.1", "normalize-strings": "^1.1.1",
"open": "8.4.0", "open": "8.4.0",
@ -92,7 +92,7 @@
"jsdoc": "3.6.7", "jsdoc": "3.6.7",
"lorem-ipsum": "2.0.4", "lorem-ipsum": "2.0.4",
"rcedit": "3.0.1", "rcedit": "3.0.1",
"webpack": "5.64.4", "webpack": "5.65.0",
"webpack-cli": "4.9.1" "webpack-cli": "4.9.1"
}, },
"optionalDependencies": { "optionalDependencies": {

View File

@ -9,7 +9,6 @@
padding: 20px; padding: 20px;
flex-basis: 0; flex-basis: 0;
flex-grow: 1; flex-grow: 1;
background-color: #ccc;
overflow: auto; overflow: auto;
} }
@ -17,6 +16,11 @@
margin: 0; margin: 0;
} }
#menu > p {
font-weight: bold;
font-size: 110%;
}
#menu ul { #menu ul {
padding-left: 20px; padding-left: 20px;
} }
@ -24,12 +28,11 @@
#main { #main {
flex-basis: 0; flex-basis: 0;
flex-grow: 3; flex-grow: 3;
background-color:#eee;
} }
#title { #title {
margin: 0; margin: 0;
padding: 20px 20px 0 20px; padding: 10px 20px 0 20px;
} }
#content { #content {

View File

@ -201,12 +201,29 @@ function getHoistedNote() {
return becca.getNote(cls.getHoistedNoteId()); 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() { function createMissingSpecialNotes() {
getSinglesNoteRoot(); getSinglesNoteRoot();
getSqlConsoleRoot(); getSqlConsoleRoot();
getSinglesNoteRoot(); getSinglesNoteRoot();
getSinglesNoteRoot(); getSinglesNoteRoot();
getGlobalNoteMap(); getGlobalNoteMap();
getShareRoot();
const hidden = getHiddenRoot(); const hidden = getHiddenRoot();

View File

@ -7,6 +7,7 @@ const Note = require('./entities/note');
const Branch = require('./entities/branch'); const Branch = require('./entities/branch');
const Attribute = require('./entities/attribute'); const Attribute = require('./entities/attribute');
const shareRoot = require('../share_root'); const shareRoot = require('../share_root');
const eventService = require("../../services/events");
function load() { function load() {
const start = Date.now(); const start = Date.now();
@ -41,8 +42,17 @@ function load() {
new Branch(row); new Branch(row);
} }
// TODO: add filter for allowed attributes const attributes = sql.getRawRows(`
for (const row of sql.getRawRows(`SELECT attributeId, noteId, type, name, value, isInheritable, position, utcDateModified FROM attributes WHERE isDeleted = 0 AND noteId IN (${noteIdStr})`, [])) { 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); 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 = { module.exports = {
load, load,

View File

@ -1,3 +1,3 @@
module.exports = { module.exports = {
SHARE_ROOT_NOTE_ID: 'root' SHARE_ROOT_NOTE_ID: 'share'
} }