Skip to content

Commit fead3cd

Browse files
committed
fix note export/import/branch prefix to use right-clicked note as opposed to current active
1 parent a7cf3cd commit fead3cd

File tree

9 files changed

+74
-108
lines changed

9 files changed

+74
-108
lines changed

package-lock.json

+52-81
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"devDependencies": {
7777
"devtron": "1.4.0",
7878
"electron": "6.0.0-beta.9",
79-
"electron-builder": "20.43.0",
79+
"electron-builder": "20.44.2",
8080
"electron-compile": "6.4.4",
8181
"electron-installer-debian": "2.0.0",
8282
"electron-packager": "13.1.1",

src/public/javascripts/desktop.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ $noteTabContainer.on("click", ".export-note-button", function () {
142142
return;
143143
}
144144

145-
exportDialog.showDialog('single');
145+
exportDialog.showDialog(treeService.getActiveNode(), 'single');
146146
});
147147

148-
$noteTabContainer.on("click", ".import-files-button", importDialog.showDialog);
148+
$noteTabContainer.on("click", ".import-files-button", () => importDialog.showDialog(treeService.getActiveNode()));
149149

150150
$('[data-toggle="tooltip"]').tooltip({
151151
html: true

src/public/javascripts/dialogs/branch_prefix.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@ const $noteTitle = $('#branch-prefix-note-title');
1212

1313
let branchId;
1414

15-
async function showDialog() {
15+
async function showDialog(node) {
1616
utils.closeActiveDialog();
1717

1818
glob.activeDialog = $dialog;
1919

2020
$dialog.modal();
2121

22-
const currentNode = treeService.getActiveNode();
23-
24-
branchId = currentNode.data.branchId;
22+
branchId = node.data.branchId;
2523
const branch = await treeCache.getBranch(branchId);
2624

2725
$treePrefixInput.val(branch.prefix);
2826

29-
const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId);
27+
const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);
3028

3129
$noteTitle.text(" - " + noteTitle);
3230
}

src/public/javascripts/dialogs/export.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import treeService from '../services/tree.js';
21
import treeUtils from "../services/tree_utils.js";
32
import utils from "../services/utils.js";
43
import messagingService from "../services/messaging.js";
54
import infoService from "../services/info.js";
65

76
const $dialog = $("#export-dialog");
87
const $form = $("#export-form");
9-
const $noteTitle = $dialog.find(".note-title");
8+
const $noteTitle = $dialog.find(".export-note-title");
109
const $subtreeFormats = $("#export-subtree-formats");
1110
const $singleFormats = $("#export-single-formats");
1211
const $subtreeType = $("#export-type-subtree");
@@ -17,8 +16,9 @@ const $exportButton = $("#export-button");
1716
const $opmlVersions = $("#opml-versions");
1817

1918
let exportId = '';
19+
let branchId = null;
2020

21-
async function showDialog(defaultType) {
21+
async function showDialog(node, defaultType) {
2222
utils.closeActiveDialog();
2323

2424
// each opening of the dialog resets the exportId so we don't associate it with previous exports anymore
@@ -46,8 +46,9 @@ async function showDialog(defaultType) {
4646

4747
$dialog.modal();
4848

49-
const currentNode = treeService.getActiveNode();
50-
const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId);
49+
branchId = node.data.branchId;
50+
51+
const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);
5152

5253
$noteTitle.html(noteTitle);
5354
}
@@ -70,9 +71,7 @@ $form.submit(() => {
7071

7172
const exportVersion = exportFormat === 'opml' ? $dialog.find("input[name='opml-version']:checked").val() : "1.0";
7273

73-
const currentNode = treeService.getActiveNode();
74-
75-
exportBranch(currentNode.data.branchId, exportType, exportFormat, exportVersion);
74+
exportBranch(branchId, exportType, exportFormat, exportVersion);
7675

7776
return false;
7877
});

src/public/javascripts/dialogs/import.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ const $codeImportedAsCodeCheckbox = $("#code-imported-as-code-checkbox");
1919
const $explodeArchivesCheckbox = $("#explode-archives-checkbox");
2020

2121
let importId;
22+
let importIntoNoteId = null;
2223

23-
async function showDialog() {
24+
async function showDialog(node) {
2425
utils.closeActiveDialog();
2526

2627
// each opening of the dialog resets the importId so we don't associate it with previous imports anymore
@@ -37,19 +38,18 @@ async function showDialog() {
3738

3839
glob.activeDialog = $dialog;
3940

40-
const currentNode = treeService.getActiveNode();
41-
$noteTitle.text(await treeUtils.getNoteTitle(currentNode.data.noteId));
41+
importIntoNoteId = node.data.noteId;
42+
43+
$noteTitle.text(await treeUtils.getNoteTitle(importIntoNoteId));
4244

4345
$dialog.modal();
4446
}
4547

4648
$form.submit(() => {
47-
const currentNode = treeService.getActiveNode();
48-
4949
// disabling so that import is not triggered again.
5050
$importButton.attr("disabled", "disabled");
5151

52-
importIntoNote(currentNode.data.noteId);
52+
importIntoNote(importIntoNoteId);
5353

5454
return false;
5555
});

src/public/javascripts/services/tree_context_menu.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ class TreeContextMenu {
132132
treeChangesService.deleteNodes(treeService.getSelectedOrActiveNodes(this.node));
133133
}
134134
else if (cmd === "export") {
135-
exportDialog.showDialog("subtree");
135+
exportDialog.showDialog(this.node,"subtree");
136136
}
137137
else if (cmd === "importIntoNote") {
138-
importDialog.showDialog();
138+
importDialog.showDialog(this.node);
139139
}
140140
else if (cmd === "collapseSubtree") {
141141
treeService.collapseTree(this.node);

0 commit comments

Comments
 (0)