mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixes
This commit is contained in:
parent
7cad386a56
commit
516e6c35da
@ -294,7 +294,7 @@ function getHashValueFromAddress() {
|
|||||||
async function loadTreeData() {
|
async function loadTreeData() {
|
||||||
const resp = await server.get('tree');
|
const resp = await server.get('tree');
|
||||||
|
|
||||||
treeCache.load(resp.notes, resp.branches);
|
treeCache.load(resp.notes, resp.branches, resp.attributes);
|
||||||
|
|
||||||
return await treeBuilder.prepareTree();
|
return await treeBuilder.prepareTree();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Branch from "../entities/branch.js";
|
import Branch from "../entities/branch.js";
|
||||||
import NoteShort from "../entities/note_short.js";
|
import NoteShort from "../entities/note_short.js";
|
||||||
import ws from "./ws.js";
|
|
||||||
import server from "./server.js";
|
|
||||||
import Attribute from "../entities/attribute.js";
|
import Attribute from "../entities/attribute.js";
|
||||||
|
import server from "./server.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TreeCache keeps a read only cache of note tree structure in frontend's memory.
|
* TreeCache keeps a read only cache of note tree structure in frontend's memory.
|
||||||
@ -127,7 +126,7 @@ class TreeCache {
|
|||||||
async reloadNotes(noteIds) {
|
async reloadNotes(noteIds) {
|
||||||
const resp = await server.post('tree/load', { noteIds });
|
const resp = await server.post('tree/load', { noteIds });
|
||||||
|
|
||||||
this.addResp(resp.notes, resp.branches);
|
this.addResp(resp.notes, resp.branches, resp.attributes);
|
||||||
|
|
||||||
for (const note of resp.notes) {
|
for (const note of resp.notes) {
|
||||||
if (note.type === 'search') {
|
if (note.type === 'search') {
|
||||||
@ -152,7 +151,7 @@ class TreeCache {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// update this note with standard (parent) branches + virtual (children) branches
|
// update this note with standard (parent) branches + virtual (children) branches
|
||||||
treeCache.addResp([note], branches);
|
treeCache.addResp([note], branches, []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +166,7 @@ class TreeCache {
|
|||||||
|
|
||||||
return noteIds.map(noteId => {
|
return noteIds.map(noteId => {
|
||||||
if (!this.notes[noteId] && !silentNotFoundError) {
|
if (!this.notes[noteId] && !silentNotFoundError) {
|
||||||
ws.logError(`Can't find note "${noteId}"`);
|
console.log(`Can't find note "${noteId}"`);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import utils from './utils.js';
|
import utils from './utils.js';
|
||||||
import toastService from "./toast.js";
|
import toastService from "./toast.js";
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import appContext from "./app_context.js";
|
|
||||||
|
|
||||||
const $outstandingSyncsCount = $("#outstanding-syncs-count");
|
const $outstandingSyncsCount = $("#outstanding-syncs-count");
|
||||||
|
|
||||||
@ -133,6 +132,8 @@ async function consumeSyncData() {
|
|||||||
const outsideSyncData = allSyncData.filter(sync => sync.sourceId !== glob.sourceId);
|
const outsideSyncData = allSyncData.filter(sync => sync.sourceId !== glob.sourceId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const appContext = (await import("./app_context.js")).default;
|
||||||
|
|
||||||
// the update process should be synchronous as a whole but individual handlers can run in parallel
|
// the update process should be synchronous as a whole but individual handlers can run in parallel
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
() => appContext.trigger('syncData', {data: allSyncData}),
|
() => appContext.trigger('syncData', {data: allSyncData}),
|
||||||
|
@ -560,7 +560,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (noteIdsToRefresh.size > 0) {
|
if (noteIdsToRefresh.size > 0) {
|
||||||
appContext.trigger('reloadNotes', {noteIds: Array.from(noteIdsToRefresh)});
|
this.appContext.trigger('reloadNotes', {noteIds: Array.from(noteIdsToRefresh)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ const sql = require('../../services/sql');
|
|||||||
const optionService = require('../../services/options');
|
const optionService = require('../../services/options');
|
||||||
const treeService = require('../../services/tree');
|
const treeService = require('../../services/tree');
|
||||||
|
|
||||||
async function getNotesAndBranches(noteIds) {
|
async function getNotesAndBranchesAndAttributes(noteIds) {
|
||||||
noteIds = Array.from(new Set(noteIds));
|
noteIds = Array.from(new Set(noteIds));
|
||||||
const notes = await treeService.getNotes(noteIds);
|
const notes = await treeService.getNotes(noteIds);
|
||||||
|
|
||||||
@ -45,20 +45,10 @@ async function getNotesAndBranches(noteIds) {
|
|||||||
FROM attributes
|
FROM attributes
|
||||||
WHERE isDeleted = 0 AND noteId IN (???)`, noteIds);
|
WHERE isDeleted = 0 AND noteId IN (???)`, noteIds);
|
||||||
|
|
||||||
for (const {noteId, type, name, value, isInheritable} of attributes) {
|
|
||||||
const note = noteMap[noteId];
|
|
||||||
|
|
||||||
note.attributes.push({
|
|
||||||
type,
|
|
||||||
name,
|
|
||||||
value,
|
|
||||||
isInheritable
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
branches,
|
branches,
|
||||||
notes
|
notes,
|
||||||
|
attributes
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,11 +70,11 @@ async function getTree() {
|
|||||||
|
|
||||||
noteIds.push('root');
|
noteIds.push('root');
|
||||||
|
|
||||||
return await getNotesAndBranches(noteIds);
|
return await getNotesAndBranchesAndAttributes(noteIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function load(req) {
|
async function load(req) {
|
||||||
return await getNotesAndBranches(req.body.noteIds);
|
return await getNotesAndBranchesAndAttributes(req.body.noteIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user