mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 20:19:05 +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 noteAttributeCache from "../services/note_attribute_cache.js";
|
||||
import ws from "../services/ws.js";
|
||||
import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||
import cssClassManager from "../services/css_class_manager.js";
|
||||
import type { Froca } from "../services/froca-interface.js";
|
||||
@ -586,7 +585,7 @@ export default class FNote {
|
||||
let childBranches = this.getChildBranches();
|
||||
|
||||
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 [];
|
||||
}
|
||||
|
||||
|
||||
@ -70,26 +70,26 @@ async function setupProtectedSession(password: string) {
|
||||
protectedSessionHolder.enableProtectedSession();
|
||||
}
|
||||
|
||||
// ws.subscribeToMessages(async (message) => {
|
||||
// if (message.type === "protectedSessionLogin") {
|
||||
// await reloadData();
|
||||
ws.subscribeToMessages(async (message) => {
|
||||
if (message.type === "protectedSessionLogin") {
|
||||
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) {
|
||||
// protectedSessionDeferred.resolve(true);
|
||||
// protectedSessionDeferred = null;
|
||||
// }
|
||||
if (protectedSessionDeferred !== null) {
|
||||
protectedSessionDeferred.resolve(true);
|
||||
protectedSessionDeferred = null;
|
||||
}
|
||||
|
||||
// toastService.showMessage(t("protected_session.started"));
|
||||
// } else if (message.type === "protectedSessionLogout") {
|
||||
// utils.reloadFrontendApp(`Protected session logout`);
|
||||
// }
|
||||
// });
|
||||
toastService.showMessage(t("protected_session.started"));
|
||||
} else if (message.type === "protectedSessionLogout") {
|
||||
utils.reloadFrontendApp(`Protected session logout`);
|
||||
}
|
||||
});
|
||||
|
||||
async function protectNote(noteId: string, protect: boolean, includingSubtree: boolean) {
|
||||
await enterProtectedSession();
|
||||
@ -106,29 +106,29 @@ function makeToast(message: Message, title: string, text: string): ToastOptions
|
||||
};
|
||||
}
|
||||
|
||||
// ws.subscribeToMessages(async (message) => {
|
||||
// if (!("taskType" in message) || message.taskType !== "protectNotes") {
|
||||
// return;
|
||||
// }
|
||||
ws.subscribeToMessages(async (message) => {
|
||||
if (!("taskType" in message) || message.taskType !== "protectNotes") {
|
||||
return;
|
||||
}
|
||||
|
||||
// const isProtecting = message.data?.protect;
|
||||
// const title = isProtecting ? t("protected_session.protecting-title") : t("protected_session.unprotecting-title");
|
||||
const isProtecting = message.data?.protect;
|
||||
const title = isProtecting ? t("protected_session.protecting-title") : t("protected_session.unprotecting-title");
|
||||
|
||||
// if (message.type === "taskError") {
|
||||
// toastService.closePersistent(message.taskId);
|
||||
// toastService.showError(message.message);
|
||||
// } else if (message.type === "taskProgressCount") {
|
||||
// const count = message.progressCount;
|
||||
// const text = isProtecting ? t("protected_session.protecting-in-progress", { count }) : t("protected_session.unprotecting-in-progress-count", { count });
|
||||
// toastService.showPersistent(makeToast(message, title, text));
|
||||
// } else if (message.type === "taskSucceeded") {
|
||||
// const text = isProtecting ? t("protected_session.protecting-finished-successfully") : t("protected_session.unprotecting-finished-successfully");
|
||||
// const toast = makeToast(message, title, text);
|
||||
// toast.closeAfter = 3000;
|
||||
if (message.type === "taskError") {
|
||||
toastService.closePersistent(message.taskId);
|
||||
toastService.showError(message.message);
|
||||
} else if (message.type === "taskProgressCount") {
|
||||
const count = message.progressCount;
|
||||
const text = isProtecting ? t("protected_session.protecting-in-progress", { count }) : t("protected_session.unprotecting-in-progress-count", { count });
|
||||
toastService.showPersistent(makeToast(message, title, text));
|
||||
} else if (message.type === "taskSucceeded") {
|
||||
const text = isProtecting ? t("protected_session.protecting-finished-successfully") : t("protected_session.unprotecting-finished-successfully");
|
||||
const toast = makeToast(message, title, text);
|
||||
toast.closeAfter = 3000;
|
||||
|
||||
// toastService.showPersistent(toast);
|
||||
// }
|
||||
// });
|
||||
toastService.showPersistent(toast);
|
||||
}
|
||||
});
|
||||
|
||||
export default {
|
||||
protectNote,
|
||||
|
||||
@ -122,17 +122,17 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root
|
||||
}
|
||||
}
|
||||
|
||||
// ws.subscribeToMessages((message) => {
|
||||
// if (message.type === "openNote") {
|
||||
// appContext.tabManager.activateOrOpenNote(message.noteId);
|
||||
ws.subscribeToMessages((message) => {
|
||||
if (message.type === "openNote") {
|
||||
appContext.tabManager.activateOrOpenNote(message.noteId);
|
||||
|
||||
// if (utils.isElectron()) {
|
||||
// const currentWindow = utils.dynamicRequire("@electron/remote").getCurrentWindow();
|
||||
if (utils.isElectron()) {
|
||||
const currentWindow = utils.dynamicRequire("@electron/remote").getCurrentWindow();
|
||||
|
||||
// currentWindow.show();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
currentWindow.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function getParentProtectedStatus(node: Fancytree.FancytreeNode) {
|
||||
return hoistedNoteService.isHoistedNode(node) ? false : node.getParent().data.isProtected;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user