Compare commits

...

9 Commits

12 changed files with 50 additions and 33 deletions

View File

@@ -1,13 +1,3 @@
-- delete duplicates https://github.com/zadam/trilium/issues/2534
DELETE FROM entity_changes WHERE isErased = 0 AND id IN (
SELECT id FROM entity_changes ec
WHERE (
SELECT COUNT(*) FROM entity_changes
WHERE ec.entityName = entity_changes.entityName
AND ec.entityId = entity_changes.entityId
) > 1
);
CREATE TABLE IF NOT EXISTS "mig_entity_changes" ( CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`entityName` TEXT NOT NULL, `entityName` TEXT NOT NULL,
@@ -23,7 +13,17 @@ CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
INSERT INTO mig_entity_changes (id, entityName, entityId, hash, isErased, changeId, sourceId, isSynced, utcDateChanged) INSERT INTO mig_entity_changes (id, entityName, entityId, hash, isErased, changeId, sourceId, isSynced, utcDateChanged)
SELECT id, entityName, entityId, hash, isErased, '', sourceId, isSynced, utcDateChanged FROM entity_changes; SELECT id, entityName, entityId, hash, isErased, '', sourceId, isSynced, utcDateChanged FROM entity_changes;
DROP TABLE entity_changes; -- delete duplicates https://github.com/zadam/trilium/issues/2534
DELETE FROM mig_entity_changes WHERE isErased = 0 AND id IN (
SELECT id FROM mig_entity_changes ec
WHERE (
SELECT COUNT(*) FROM mig_entity_changes
WHERE ec.entityName = mig_entity_changes.entityName
AND ec.entityId = mig_entity_changes.entityId
) > 1
);
DROP TABLE entity_changes;
ALTER TABLE mig_entity_changes RENAME TO entity_changes; ALTER TABLE mig_entity_changes RENAME TO entity_changes;

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "trilium", "name": "trilium",
"version": "0.49.2-beta", "version": "0.49.4",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "trilium", "name": "trilium",
"version": "0.49.2-beta", "version": "0.49.4",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"dependencies": { "dependencies": {
"@electron/remote": "2.0.1", "@electron/remote": "2.0.1",

View File

@@ -2,7 +2,7 @@
"name": "trilium", "name": "trilium",
"productName": "Trilium Notes", "productName": "Trilium Notes",
"description": "Trilium Notes", "description": "Trilium Notes",
"version": "0.49.4", "version": "0.49.5",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"main": "electron.js", "main": "electron.js",
"bin": { "bin": {

View File

@@ -865,11 +865,13 @@ class Note extends AbstractEntity {
this.ancestorCache = []; this.ancestorCache = [];
for (const parent of this.parents) { for (const parent of this.parents) {
if (!noteIds.has(parent.noteId)) { if (noteIds.has(parent.noteId)) {
this.ancestorCache.push(parent); continue;
noteIds.add(parent.noteId);
} }
this.ancestorCache.push(parent);
noteIds.add(parent.noteId);
for (const ancestorNote of parent.getAncestors()) { for (const ancestorNote of parent.getAncestors()) {
if (!noteIds.has(ancestorNote.noteId)) { if (!noteIds.has(ancestorNote.noteId)) {
this.ancestorCache.push(ancestorNote); this.ancestorCache.push(ancestorNote);

View File

@@ -790,7 +790,7 @@ class NoteShort {
const parentNote = froca.notes[parentNoteId]; const parentNote = froca.notes[parentNoteId];
if (!parentNote) { if (!parentNote || parentNote.type === 'search') {
continue; continue;
} }

View File

@@ -1,7 +1,7 @@
import server from './server.js'; import server from './server.js';
import toastService from "./toast.js"; import toastService from "./toast.js";
async function syncNow() { async function syncNow(ignoreNotConfigured = false) {
const result = await server.post('sync/now'); const result = await server.post('sync/now');
if (result.success) { if (result.success) {
@@ -12,7 +12,9 @@ async function syncNow() {
result.message = result.message.substr(0, 200) + "..."; result.message = result.message.substr(0, 200) + "...";
} }
toastService.showError("Sync failed: " + result.message); if (!ignoreNotConfigured || result.errorCode !== 'NOT_CONFIGURED') {
toastService.showError("Sync failed: " + result.message);
}
} }
} }

View File

@@ -21,6 +21,7 @@ import ReadOnlyCodeTypeWidget from "./type_widgets/read_only_code.js";
import NoneTypeWidget from "./type_widgets/none.js"; import NoneTypeWidget from "./type_widgets/none.js";
import attributeService from "../services/attributes.js"; import attributeService from "../services/attributes.js";
import NoteMapTypeWidget from "./type_widgets/note_map.js"; import NoteMapTypeWidget from "./type_widgets/note_map.js";
import attributeRenderer from "../services/attribute_renderer.js";
const TPL = ` const TPL = `
<div class="note-detail"> <div class="note-detail">
@@ -209,8 +210,17 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
await libraryLoader.requireLibrary(libraryLoader.PRINT_THIS); await libraryLoader.requireLibrary(libraryLoader.PRINT_THIS);
let $promotedAttributes = $("");
if (this.note.getPromotedDefinitionAttributes().length > 0) {
$promotedAttributes = (await attributeRenderer.renderNormalAttributes(this.note)).$renderedAttributes;
}
this.$widget.find('.note-detail-printable:visible').printThis({ this.$widget.find('.note-detail-printable:visible').printThis({
header: $("<h2>").text(this.note && this.note.title).prop('outerHTML'), header: $("<div>")
.append($("<h2>").text(this.note.title))
.append($promotedAttributes)
.prop('outerHTML'),
footer: ` footer: `
<script src="libraries/katex/katex.min.js"></script> <script src="libraries/katex/katex.min.js"></script>
<script src="libraries/katex/mhchem.min.js"></script> <script src="libraries/katex/mhchem.min.js"></script>

View File

@@ -13,7 +13,7 @@ const TPL = `
} }
</style> </style>
<span class="share-text"></span> <a class="share-link external"></a>. For help visit <a href="https://github.com/zadam/trilium/wiki/Sharing">wiki</a>. <span class="shared-text"></span> <a class="shared-link external"></a>. For help visit <a href="https://github.com/zadam/trilium/wiki/Sharing">wiki</a>.
</div>`; </div>`;
export default class SharedInfoWidget extends NoteContextAwareWidget { export default class SharedInfoWidget extends NoteContextAwareWidget {
@@ -23,8 +23,8 @@ export default class SharedInfoWidget extends NoteContextAwareWidget {
doRender() { doRender() {
this.$widget = $(TPL); this.$widget = $(TPL);
this.$shareLink = this.$widget.find(".share-link"); this.$sharedLink = this.$widget.find(".shared-link");
this.$shareText = this.$widget.find(".share-text"); this.$sharedText = this.$widget.find(".shared-text");
this.contentSized(); this.contentSized();
} }
@@ -36,14 +36,14 @@ export default class SharedInfoWidget extends NoteContextAwareWidget {
if (syncServerHost) { if (syncServerHost) {
link = syncServerHost + "/share/" + shareId; link = syncServerHost + "/share/" + shareId;
this.$shareText.text("This note is shared publicly on"); this.$sharedText.text("This note is shared publicly on");
} }
else { else {
link = location.protocol + '//' + location.host + location.pathname + "share/" + shareId; link = location.protocol + '//' + location.host + location.pathname + "share/" + shareId;
this.$shareText.text("This note is shared locally on"); this.$sharedText.text("This note is shared locally on");
} }
this.$shareLink.attr("href", link).text(link); this.$sharedLink.attr("href", link).text(link);
} }
entitiesReloadedEvent({loadResults}) { entitiesReloadedEvent({loadResults}) {

View File

@@ -2,6 +2,7 @@ import SwitchWidget from "./switch.js";
import branchService from "../services/branches.js"; import branchService from "../services/branches.js";
import server from "../services/server.js"; import server from "../services/server.js";
import utils from "../services/utils.js"; import utils from "../services/utils.js";
import syncService from "../services/sync.js";
export default class SharedSwitchWidget extends SwitchWidget { export default class SharedSwitchWidget extends SwitchWidget {
isEnabled() { isEnabled() {
@@ -21,8 +22,10 @@ export default class SharedSwitchWidget extends SwitchWidget {
this.$helpButton.on('click', e => utils.openHelp(e)); this.$helpButton.on('click', e => utils.openHelp(e));
} }
switchOn() { async switchOn() {
branchService.cloneNoteToNote(this.noteId, 'share'); await branchService.cloneNoteToNote(this.noteId, 'share');
syncService.syncNow(true);
} }
async switchOff() { async switchOff() {
@@ -43,6 +46,8 @@ export default class SharedSwitchWidget extends SwitchWidget {
} }
await server.remove(`branches/${shareBranch.branchId}?taskId=no-progress-reporting`); await server.remove(`branches/${shareBranch.branchId}?taskId=no-progress-reporting`);
syncService.syncNow(true);
} }
async refreshWithNote(note) { async refreshWithNote(note) {

View File

@@ -1 +1 @@
module.exports = { buildDate:"2022-01-09T22:32:13+01:00", buildRevision: "be59f248e8387c268471946da99979939c8d2c1d" }; module.exports = { buildDate:"2022-01-14T21:40:37+01:00", buildRevision: "77c6c4617b634226e12ead172482fe1fe92bc360" };

View File

@@ -26,7 +26,7 @@ async function sync() {
try { try {
return await syncMutexService.doExclusively(async () => { return await syncMutexService.doExclusively(async () => {
if (!syncOptions.isSyncSetup()) { if (!syncOptions.isSyncSetup()) {
return { success: false, message: 'Sync not configured' }; return { success: false, errorCode: 'NOT_CONFIGURED', message: 'Sync not configured' };
} }
let continueSync = false; let continueSync = false;

View File

@@ -41,8 +41,6 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) {
const existing = getExistingBranch(parentNoteId, childNoteId); const existing = getExistingBranch(parentNoteId, childNoteId);
console.log("BBBB", existing);
if (existing && (branchId === null || existing.branchId !== branchId)) { if (existing && (branchId === null || existing.branchId !== branchId)) {
const parentNote = becca.getNote(parentNoteId); const parentNote = becca.getNote(parentNoteId);
const childNote = becca.getNote(childNoteId); const childNote = becca.getNote(childNoteId);