mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
improvements in frontend sync (WIP)
This commit is contained in:
parent
d27fcaf317
commit
66374bf95f
@ -37,7 +37,7 @@ export default class KeyboardShortcutsOptions {
|
|||||||
constructor() {
|
constructor() {
|
||||||
$("#options-keyboard-shortcuts").html(TPL);
|
$("#options-keyboard-shortcuts").html(TPL);
|
||||||
|
|
||||||
$("#options-keyboard-shortcuts-reload-app").on("click", () => utils.reloadApp());
|
$("#options-keyboard-shortcuts-reload-app").on("click", () => utils.reloadFrontendApp());
|
||||||
|
|
||||||
const $table = $("#keyboard-shortcut-table tbody");
|
const $table = $("#keyboard-shortcut-table tbody");
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ async function moveNodeUpInHierarchy(node) {
|
|||||||
|
|
||||||
if (!hoistedNoteService.isTopLevelNode(node) && node.getParent().getChildren().length <= 1) {
|
if (!hoistedNoteService.isTopLevelNode(node) && node.getParent().getChildren().length <= 1) {
|
||||||
node.getParent().folder = false;
|
node.getParent().folder = false;
|
||||||
node.getParent().getTitle();
|
node.getParent().renderTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ export default class Entrypoints extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reloadFrontendAppCommand() {
|
reloadFrontendAppCommand() {
|
||||||
utils.reloadApp();
|
utils.reloadFrontendApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
logoutCommand() {
|
logoutCommand() {
|
||||||
@ -169,7 +169,7 @@ export default class Entrypoints extends Component {
|
|||||||
async switchToDesktopVersionCommand() {
|
async switchToDesktopVersionCommand() {
|
||||||
utils.setCookie('trilium-device', 'desktop');
|
utils.setCookie('trilium-device', 'desktop');
|
||||||
|
|
||||||
utils.reloadApp();
|
utils.reloadFrontendApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
async openInWindowCommand({notePath, hoistedNoteId}) {
|
async openInWindowCommand({notePath, hoistedNoteId}) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import LoadResults from "./load_results.js";
|
import LoadResults from "./load_results.js";
|
||||||
import froca from "./froca.js";
|
import froca from "./froca.js";
|
||||||
|
import utils from "./utils.js";
|
||||||
import options from "./options.js";
|
import options from "./options.js";
|
||||||
import noteAttributeCache from "./note_attribute_cache.js";
|
import noteAttributeCache from "./note_attribute_cache.js";
|
||||||
import Branch from "../entities/branch.js";
|
import Branch from "../entities/branch.js";
|
||||||
@ -84,6 +85,11 @@ function processNoteChange(loadResults, ec) {
|
|||||||
|
|
||||||
loadResults.addNote(ec.entityId, ec.sourceId);
|
loadResults.addNote(ec.entityId, ec.sourceId);
|
||||||
|
|
||||||
|
if (ec.isErased && ec.entityId in froca.notes) {
|
||||||
|
utils.reloadFrontendApp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ec.isErased || ec.entity?.isDeleted) {
|
if (ec.isErased || ec.entity?.isDeleted) {
|
||||||
delete froca.notes[ec.entityId];
|
delete froca.notes[ec.entityId];
|
||||||
}
|
}
|
||||||
@ -93,6 +99,11 @@ function processNoteChange(loadResults, ec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processBranchChange(loadResults, ec) {
|
function processBranchChange(loadResults, ec) {
|
||||||
|
if (ec.isErased && ec.entityId in froca.branches) {
|
||||||
|
utils.reloadFrontendApp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let branch = froca.branches[ec.entityId];
|
let branch = froca.branches[ec.entityId];
|
||||||
|
|
||||||
if (ec.isErased || ec.entity?.isDeleted) {
|
if (ec.isErased || ec.entity?.isDeleted) {
|
||||||
@ -127,7 +138,7 @@ function processBranchChange(loadResults, ec) {
|
|||||||
branch.update(ec.entity);
|
branch.update(ec.entity);
|
||||||
}
|
}
|
||||||
else if (childNote || parentNote) {
|
else if (childNote || parentNote) {
|
||||||
froca.branches[branch.branchId] = branch = new Branch(froca, ec.entity);
|
froca.branches[ec.entityId] = branch = new Branch(froca, ec.entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (childNote) {
|
if (childNote) {
|
||||||
@ -166,6 +177,11 @@ function processNoteReordering(loadResults, ec) {
|
|||||||
function processAttributeChange(loadResults, ec) {
|
function processAttributeChange(loadResults, ec) {
|
||||||
let attribute = froca.attributes[ec.entityId];
|
let attribute = froca.attributes[ec.entityId];
|
||||||
|
|
||||||
|
if (ec.isErased && ec.entityId in froca.attributes) {
|
||||||
|
utils.reloadFrontendApp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ec.isErased || ec.entity?.isDeleted) {
|
if (ec.isErased || ec.entity?.isDeleted) {
|
||||||
if (attribute) {
|
if (attribute) {
|
||||||
const sourceNote = froca.notes[attribute.noteId];
|
const sourceNote = froca.notes[attribute.noteId];
|
||||||
|
@ -69,7 +69,7 @@ ws.subscribeToMessages(async message => {
|
|||||||
toastService.showMessage("Protected session has been started.");
|
toastService.showMessage("Protected session has been started.");
|
||||||
}
|
}
|
||||||
else if (message.type === 'protectedSessionLogout') {
|
else if (message.type === 'protectedSessionLogout') {
|
||||||
utils.reloadApp();
|
utils.reloadFrontendApp();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function reloadApp() {
|
function reloadFrontendApp() {
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ function isValidAttributeName(name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
reloadApp,
|
reloadFrontendApp,
|
||||||
parseDate,
|
parseDate,
|
||||||
padNum,
|
padNum,
|
||||||
formatTime,
|
formatTime,
|
||||||
|
@ -149,7 +149,7 @@ async function consumeFrontendUpdateData() {
|
|||||||
if (!glob.isDev && !options.is('debugModeEnabled')) {
|
if (!glob.isDev && !options.is('debugModeEnabled')) {
|
||||||
// if there's an error in updating the frontend then the easy option to recover is to reload the frontend completely
|
// if there's an error in updating the frontend then the easy option to recover is to reload the frontend completely
|
||||||
|
|
||||||
utils.reloadApp();
|
utils.reloadFrontendApp();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("nonProcessedEntityChanges causing the timeout", nonProcessedEntityChanges);
|
console.log("nonProcessedEntityChanges causing the timeout", nonProcessedEntityChanges);
|
||||||
|
@ -139,7 +139,7 @@ async function checkOutstandingSyncs() {
|
|||||||
remote.app.exit(0);
|
remote.app.exit(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
utils.reloadApp();
|
utils.reloadFrontendApp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1031,9 +1031,10 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
// make sure it's loaded
|
// make sure it's loaded
|
||||||
await froca.getNote(branch.noteId);
|
await froca.getNote(branch.noteId);
|
||||||
|
const frocaBranch = froca.getBranch(branch.branchId);
|
||||||
|
|
||||||
// we're forcing lazy since it's not clear if the whole required subtree is in froca
|
// we're forcing lazy since it's not clear if the whole required subtree is in froca
|
||||||
parentNode.addChildren([this.prepareNode(branch, true)]);
|
parentNode.addChildren([this.prepareNode(frocaBranch, true)]);
|
||||||
|
|
||||||
this.sortChildren(parentNode);
|
this.sortChildren(parentNode);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user