mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 04:29:01 +01:00
fix(client/print): circular dependency affecting ws
This commit is contained in:
parent
08d2cc2ae5
commit
1514432f77
@ -1,6 +1,5 @@
|
|||||||
import server from "../services/server.js";
|
import server from "../services/server.js";
|
||||||
import noteAttributeCache from "../services/note_attribute_cache.js";
|
import noteAttributeCache from "../services/note_attribute_cache.js";
|
||||||
import ws from "../services/ws.js";
|
|
||||||
import protectedSessionHolder from "../services/protected_session_holder.js";
|
import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||||
import cssClassManager from "../services/css_class_manager.js";
|
import cssClassManager from "../services/css_class_manager.js";
|
||||||
import type { Froca } from "../services/froca-interface.js";
|
import type { Froca } from "../services/froca-interface.js";
|
||||||
@ -586,7 +585,7 @@ export default class FNote {
|
|||||||
let childBranches = this.getChildBranches();
|
let childBranches = this.getChildBranches();
|
||||||
|
|
||||||
if (!childBranches) {
|
if (!childBranches) {
|
||||||
ws.logError(`No children for '${this.noteId}'. This shouldn't happen.`);
|
console.error(`No children for '${this.noteId}'. This shouldn't happen.`);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,26 +70,26 @@ async function setupProtectedSession(password: string) {
|
|||||||
protectedSessionHolder.enableProtectedSession();
|
protectedSessionHolder.enableProtectedSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ws.subscribeToMessages(async (message) => {
|
ws.subscribeToMessages(async (message) => {
|
||||||
// if (message.type === "protectedSessionLogin") {
|
if (message.type === "protectedSessionLogin") {
|
||||||
// await reloadData();
|
await reloadData();
|
||||||
|
|
||||||
// await appContext.triggerEvent("frocaReloaded", {});
|
await appContext.triggerEvent("frocaReloaded", {});
|
||||||
|
|
||||||
// appContext.triggerEvent("protectedSessionStarted", {});
|
appContext.triggerEvent("protectedSessionStarted", {});
|
||||||
|
|
||||||
// appContext.triggerCommand("closeProtectedSessionPasswordDialog");
|
appContext.triggerCommand("closeProtectedSessionPasswordDialog");
|
||||||
|
|
||||||
// if (protectedSessionDeferred !== null) {
|
if (protectedSessionDeferred !== null) {
|
||||||
// protectedSessionDeferred.resolve(true);
|
protectedSessionDeferred.resolve(true);
|
||||||
// protectedSessionDeferred = null;
|
protectedSessionDeferred = null;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// toastService.showMessage(t("protected_session.started"));
|
toastService.showMessage(t("protected_session.started"));
|
||||||
// } else if (message.type === "protectedSessionLogout") {
|
} else if (message.type === "protectedSessionLogout") {
|
||||||
// utils.reloadFrontendApp(`Protected session logout`);
|
utils.reloadFrontendApp(`Protected session logout`);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
async function protectNote(noteId: string, protect: boolean, includingSubtree: boolean) {
|
async function protectNote(noteId: string, protect: boolean, includingSubtree: boolean) {
|
||||||
await enterProtectedSession();
|
await enterProtectedSession();
|
||||||
@ -106,29 +106,29 @@ function makeToast(message: Message, title: string, text: string): ToastOptions
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ws.subscribeToMessages(async (message) => {
|
ws.subscribeToMessages(async (message) => {
|
||||||
// if (!("taskType" in message) || message.taskType !== "protectNotes") {
|
if (!("taskType" in message) || message.taskType !== "protectNotes") {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// const isProtecting = message.data?.protect;
|
const isProtecting = message.data?.protect;
|
||||||
// const title = isProtecting ? t("protected_session.protecting-title") : t("protected_session.unprotecting-title");
|
const title = isProtecting ? t("protected_session.protecting-title") : t("protected_session.unprotecting-title");
|
||||||
|
|
||||||
// if (message.type === "taskError") {
|
if (message.type === "taskError") {
|
||||||
// toastService.closePersistent(message.taskId);
|
toastService.closePersistent(message.taskId);
|
||||||
// toastService.showError(message.message);
|
toastService.showError(message.message);
|
||||||
// } else if (message.type === "taskProgressCount") {
|
} else if (message.type === "taskProgressCount") {
|
||||||
// const count = message.progressCount;
|
const count = message.progressCount;
|
||||||
// const text = isProtecting ? t("protected_session.protecting-in-progress", { count }) : t("protected_session.unprotecting-in-progress-count", { count });
|
const text = isProtecting ? t("protected_session.protecting-in-progress", { count }) : t("protected_session.unprotecting-in-progress-count", { count });
|
||||||
// toastService.showPersistent(makeToast(message, title, text));
|
toastService.showPersistent(makeToast(message, title, text));
|
||||||
// } else if (message.type === "taskSucceeded") {
|
} else if (message.type === "taskSucceeded") {
|
||||||
// const text = isProtecting ? t("protected_session.protecting-finished-successfully") : t("protected_session.unprotecting-finished-successfully");
|
const text = isProtecting ? t("protected_session.protecting-finished-successfully") : t("protected_session.unprotecting-finished-successfully");
|
||||||
// const toast = makeToast(message, title, text);
|
const toast = makeToast(message, title, text);
|
||||||
// toast.closeAfter = 3000;
|
toast.closeAfter = 3000;
|
||||||
|
|
||||||
// toastService.showPersistent(toast);
|
toastService.showPersistent(toast);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
protectNote,
|
protectNote,
|
||||||
|
|||||||
@ -122,17 +122,17 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ws.subscribeToMessages((message) => {
|
ws.subscribeToMessages((message) => {
|
||||||
// if (message.type === "openNote") {
|
if (message.type === "openNote") {
|
||||||
// appContext.tabManager.activateOrOpenNote(message.noteId);
|
appContext.tabManager.activateOrOpenNote(message.noteId);
|
||||||
|
|
||||||
// if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
// const currentWindow = utils.dynamicRequire("@electron/remote").getCurrentWindow();
|
const currentWindow = utils.dynamicRequire("@electron/remote").getCurrentWindow();
|
||||||
|
|
||||||
// currentWindow.show();
|
currentWindow.show();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
function getParentProtectedStatus(node: Fancytree.FancytreeNode) {
|
function getParentProtectedStatus(node: Fancytree.FancytreeNode) {
|
||||||
return hoistedNoteService.isHoistedNode(node) ? false : node.getParent().data.isProtected;
|
return hoistedNoteService.isHoistedNode(node) ? false : node.getParent().data.isProtected;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user