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() { showWidgets() {
const rootContainer = this.layout.getRootWidget(this); 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.components = [
this.tabManager, this.tabManager,

View File

@ -1,11 +1,9 @@
import treeService from './tree.js';
import utils from './utils.js'; import utils from './utils.js';
import server from './server.js'; import server from './server.js';
import toastService from "./toast.js"; import toastService from "./toast.js";
import treeCache from "./tree_cache.js"; import treeCache from "./tree_cache.js";
import hoistedNoteService from "./hoisted_note.js"; import hoistedNoteService from "./hoisted_note.js";
import ws from "./ws.js"; import ws from "./ws.js";
import appContext from "./app_context.js";
async function moveBeforeBranch(branchIdsToMove, beforeBranchId) { async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
branchIdsToMove = await filterRootNote(branchIdsToMove); 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; return true;
} }

View File

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

View File

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

View File

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

View File

@ -7,12 +7,6 @@ class BasicWidget extends Component {
keyboardActionsService.updateDisplayedShortcuts($widget); 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()); this.toggle(this.isEnabled());
return $widget; return $widget;

View File

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