mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
Merge branch 'stable'
This commit is contained in:
commit
093dfb4a39
@ -67,12 +67,9 @@ function connectWebSocket() {
|
|||||||
|
|
||||||
// use wss for secure messaging
|
// use wss for secure messaging
|
||||||
const ws = new WebSocket(protocol + "://" + location.host);
|
const ws = new WebSocket(protocol + "://" + location.host);
|
||||||
ws.onopen = event => console.debug(utils.now(), "Connected to server with WebSocket");
|
ws.onopen = () => console.debug(utils.now(), "Connected to server with WebSocket");
|
||||||
ws.onmessage = handleMessage;
|
ws.onmessage = handleMessage;
|
||||||
ws.onclose = function(){
|
// we're not handling ws.onclose here because reconnection is done in sendPing()
|
||||||
// Try to reconnect in 5 seconds
|
|
||||||
setTimeout(() => connectWebSocket(), 5000);
|
|
||||||
};
|
|
||||||
|
|
||||||
return ws;
|
return ws;
|
||||||
}
|
}
|
||||||
@ -88,13 +85,17 @@ setTimeout(() => {
|
|||||||
console.log("Lost connection to server");
|
console.log("Lost connection to server");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (ws.readyState === ws.OPEN) {
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
type: 'ping',
|
type: 'ping',
|
||||||
lastSyncId: lastSyncId
|
lastSyncId: lastSyncId
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
catch (e) {} // if the connection is closed then this produces a lot of messages
|
else if (ws.readyState === ws.CLOSED || ws.readyState === ws.CLOSING) {
|
||||||
|
console.log("WS closed or closing, trying to reconnect");
|
||||||
|
|
||||||
|
ws = connectWebSocket();
|
||||||
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class TabContext {
|
|||||||
this.$unprotectButton = this.$tabContent.find(".unprotect-button");
|
this.$unprotectButton = this.$tabContent.find(".unprotect-button");
|
||||||
this.$unprotectButton.click(protectedSessionService.unprotectNoteAndSendToServer);
|
this.$unprotectButton.click(protectedSessionService.unprotectNoteAndSendToServer);
|
||||||
|
|
||||||
console.log(`Created note tab ${this.tabId}`);
|
console.debug(`Created note tab ${this.tabId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
setNote(note, notePath) {
|
setNote(note, notePath) {
|
||||||
@ -131,7 +131,7 @@ class TabContext {
|
|||||||
|
|
||||||
this.showPaths();
|
this.showPaths();
|
||||||
|
|
||||||
console.log(`Switched tab ${this.tabId} to ${this.noteId}`);
|
console.debug(`Switched tab ${this.tabId} to ${this.noteId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
|
@ -635,18 +635,18 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (target === 'after') {
|
if (target === 'after') {
|
||||||
console.log(`Appending node...`); // to debug duplicated nodes
|
|
||||||
|
|
||||||
await node.appendSibling(newNode).setActive(true);
|
await node.appendSibling(newNode).setActive(true);
|
||||||
}
|
}
|
||||||
else if (target === 'into') {
|
else if (target === 'into') {
|
||||||
if (!node.getChildren() && node.isFolder()) {
|
if (!node.getChildren() && node.isFolder()) {
|
||||||
|
// folder is not loaded - load will bring up the note since it was already put into cache
|
||||||
|
await node.load(true);
|
||||||
|
|
||||||
await node.setExpanded();
|
await node.setExpanded();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
console.log(`Adding node as child...`); // to debug duplicated nodes
|
|
||||||
|
|
||||||
node.addChildren(newNode);
|
node.addChildren(newNode);
|
||||||
|
}
|
||||||
|
|
||||||
await node.getLastChild().setActive(true);
|
await node.getLastChild().setActive(true);
|
||||||
|
|
||||||
@ -754,10 +754,12 @@ utils.bindShortcut('ctrl+o', async () => {
|
|||||||
async function createNoteInto() {
|
async function createNoteInto() {
|
||||||
const node = getActiveNode();
|
const node = getActiveNode();
|
||||||
|
|
||||||
|
if (node) {
|
||||||
await createNote(node, node.data.noteId, 'into', {
|
await createNote(node, node.data.noteId, 'into', {
|
||||||
isProtected: node.data.isProtected,
|
isProtected: node.data.isProtected,
|
||||||
saveSelection: true
|
saveSelection: true
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkFolderStatus(node) {
|
async function checkFolderStatus(node) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user