This commit is contained in:
zadam 2020-02-09 22:31:52 +01:00
parent 99ea238c3f
commit 7767edd82f
7 changed files with 25 additions and 24 deletions

View file

@ -29,8 +29,15 @@ class AppContext {
showWidgets() {
const rootContainer = this.layout.getRootWidget(this);
const $renderedWidget = rootContainer.render();
$("body").append(rootContainer.render());
$("body").append($renderedWidget);
$renderedWidget.on('click', "[data-trigger-event]", e => {
const eventName = $(e.target).attr('data-trigger-event');
this.trigger(eventName);
});
this.components = [
this.tabManager,

View file

@ -1,11 +1,9 @@
import treeService from './tree.js';
import utils from './utils.js';
import server from './server.js';
import toastService from "./toast.js";
import treeCache from "./tree_cache.js";
import hoistedNoteService from "./hoisted_note.js";
import ws from "./ws.js";
import appContext from "./app_context.js";
async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
branchIdsToMove = await filterRootNote(branchIdsToMove);
@ -121,8 +119,6 @@ async function deleteNodes(branchIdsToDelete) {
}
}
const noteIds = Array.from(new Set(nodes.map(node => node.getParent().data.noteId)));
return true;
}

View file

@ -100,15 +100,19 @@ class TabContext extends Component {
}
}
noteDeletedListener({noteId}) {
if (this.noteId === noteId) {
this.noteId = null;
this.notePath = null;
async entitiesReloadedListener({loadResults}) {
if (loadResults.isNoteReloaded(this.noteId)) {
const note = await treeCache.getNote(this.noteId);
this.trigger('tabNoteSwitched', {
tabId: this.tabId,
notePath: this.notePath
});
if (note.isDeleted) {
this.noteId = null;
this.notePath = null;
this.trigger('tabNoteSwitched', {
tabId: this.tabId,
notePath: this.notePath
});
}
}
}
}

View file

@ -86,7 +86,7 @@ async function getRunPath(notePath) {
break;
}
else {
ws.logError("No parents, can't activate node.");
console.log("No parents so no run path.");
return;
}
}

View file

@ -218,6 +218,9 @@ async function processSyncRows(syncRows) {
const parentNote = treeCache.notes[sync.entity.parentNoteId];
if (branch) {
branch.update(sync.entity);
loadResults.addBranch(sync.entityId, sync.sourceId);
if (sync.entity.isDeleted) {
if (childNote) {
childNote.parents = childNote.parents.filter(parentNoteId => parentNoteId !== sync.entity.parentNoteId);
@ -230,9 +233,6 @@ async function processSyncRows(syncRows) {
}
}
else {
branch.update(sync.entity);
loadResults.addBranch(sync.entityId, sync.sourceId);
if (childNote) {
childNote.addParent(branch.parentNoteId, branch.branchId);
}

View file

@ -7,12 +7,6 @@ class BasicWidget extends Component {
keyboardActionsService.updateDisplayedShortcuts($widget);
$widget.find("[data-trigger-event]").on('click', e => {
const eventName = $(e.target).attr('data-trigger-event');
this.appContext.trigger(eventName);
});
this.toggle(this.isEnabled());
return $widget;

View file

@ -473,7 +473,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
this.tabManager.getActiveTabContext().setNote(notePath);
}
node.remove();
noteIdsToReload.add(branch.parentNoteId);
}
else {
noteIdsToUpdate.add(branch.noteId);