mirror of
https://github.com/TriliumNext/Trilium.git
synced 2025-12-10 03:53:37 -06:00
refactor(toast): rename delay to timeout
This commit is contained in:
parent
da17a63ef5
commit
7463570e76
@ -216,7 +216,7 @@ ws.subscribeToMessages(async (message) => {
|
||||
toastService.showPersistent(makeToast(message.taskId, t("branches.delete-notes-in-progress", { count: message.progressCount })));
|
||||
} else if (message.type === "taskSucceeded") {
|
||||
const toast = makeToast(message.taskId, t("branches.delete-finished-successfully"));
|
||||
toast.delay = 5000;
|
||||
toast.timeout = 5000;
|
||||
|
||||
toastService.showPersistent(toast);
|
||||
}
|
||||
@ -234,7 +234,7 @@ ws.subscribeToMessages(async (message) => {
|
||||
toastService.showPersistent(makeToast(message.taskId, t("branches.undeleting-notes-in-progress", { count: message.progressCount })));
|
||||
} else if (message.type === "taskSucceeded") {
|
||||
const toast = makeToast(message.taskId, t("branches.undeleting-notes-finished-successfully"));
|
||||
toast.delay = 5000;
|
||||
toast.timeout = 5000;
|
||||
|
||||
toastService.showPersistent(toast);
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ ws.subscribeToMessages(async (message) => {
|
||||
toastService.showPersistent(makeToast(message.taskId, t("import.in-progress", { progress: message.progressCount })));
|
||||
} else if (message.type === "taskSucceeded") {
|
||||
const toast = makeToast(message.taskId, t("import.successful"));
|
||||
toast.delay = 5000;
|
||||
toast.timeout = 5000;
|
||||
|
||||
toastService.showPersistent(toast);
|
||||
|
||||
@ -100,7 +100,7 @@ ws.subscribeToMessages(async (message: WebSocketMessage) => {
|
||||
toastService.showPersistent(makeToast(message.taskId, t("import.in-progress", { progress: message.progressCount })));
|
||||
} else if (message.type === "taskSucceeded") {
|
||||
const toast = makeToast(message.taskId, t("import.successful"));
|
||||
toast.delay = 5000;
|
||||
toast.timeout = 5000;
|
||||
|
||||
toastService.showPersistent(toast);
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ ws.subscribeToMessages(async (message) => {
|
||||
} 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.delay = 3000;
|
||||
toast.timeout = 3000;
|
||||
|
||||
toastService.showPersistent(toast);
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ export interface ToastOptions {
|
||||
icon: string;
|
||||
title?: string;
|
||||
message: string;
|
||||
delay?: number;
|
||||
timeout?: number;
|
||||
autohide?: boolean;
|
||||
progress?: number;
|
||||
}
|
||||
@ -28,29 +28,29 @@ function closePersistent(id: string) {
|
||||
removeToastFromStore(id);
|
||||
}
|
||||
|
||||
function showMessage(message: string, delay = 2000, icon = "bx bx-check") {
|
||||
function showMessage(message: string, timeout = 2000, icon = "bx bx-check") {
|
||||
console.debug(utils.now(), "message:", message);
|
||||
|
||||
addToast({
|
||||
icon,
|
||||
message,
|
||||
autohide: true,
|
||||
delay
|
||||
timeout
|
||||
});
|
||||
}
|
||||
|
||||
export function showError(message: string, delay = 10000) {
|
||||
export function showError(message: string, timeout = 10000) {
|
||||
console.log(utils.now(), "error: ", message);
|
||||
|
||||
addToast({
|
||||
icon: "bx bx-error-circle",
|
||||
message,
|
||||
autohide: true,
|
||||
delay
|
||||
timeout
|
||||
})
|
||||
}
|
||||
|
||||
function showErrorTitleAndMessage(title: string, message: string, delay = 10000) {
|
||||
function showErrorTitleAndMessage(title: string, message: string, timeout = 10000) {
|
||||
console.log(utils.now(), "error: ", message);
|
||||
|
||||
addToast({
|
||||
@ -58,7 +58,7 @@ function showErrorTitleAndMessage(title: string, message: string, delay = 10000)
|
||||
icon: "bx bx-error-circle",
|
||||
message,
|
||||
autohide: true,
|
||||
delay
|
||||
timeout
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -17,13 +17,13 @@ export default function ToastContainer() {
|
||||
)
|
||||
}
|
||||
|
||||
function Toast({ id, title, autohide, delay, progress, message, icon }: ToastOptionsWithRequiredId) {
|
||||
function Toast({ id, title, autohide, timeout, progress, message, icon }: ToastOptionsWithRequiredId) {
|
||||
// Autohide.
|
||||
useEffect(() => {
|
||||
if (!autohide || !id) return;
|
||||
const timeout = setTimeout(() => removeToastFromStore(id), delay || DEFAULT_DELAY);
|
||||
return () => clearTimeout(timeout);
|
||||
}, [ autohide, id, delay ]);
|
||||
const timerId = setTimeout(() => removeToastFromStore(id), timeout || DEFAULT_DELAY);
|
||||
return () => clearTimeout(timerId);
|
||||
}, [ autohide, id, timeout ]);
|
||||
|
||||
const closeButton = <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close" />;
|
||||
const toastIcon = <Icon icon={icon.startsWith("bx ") ? icon : `bx bx-${icon}`} />;
|
||||
|
||||
@ -152,7 +152,7 @@ ws.subscribeToMessages(async (message) => {
|
||||
toastService.showPersistent(makeToast(message.taskId, t("export.export_in_progress", { progressCount: message.progressCount })));
|
||||
} else if (message.type === "taskSucceeded") {
|
||||
const toast = makeToast(message.taskId, t("export.export_finished_successfully"));
|
||||
toast.delay = 5000;
|
||||
toast.timeout = 5000;
|
||||
|
||||
toastService.showPersistent(toast);
|
||||
}
|
||||
|
||||
@ -737,7 +737,7 @@ export function useNoteTreeDrag(containerRef: MutableRef<HTMLElement | null | un
|
||||
toast.showPersistent({
|
||||
...dragNotEnabledMessage,
|
||||
id: "drag-not-enabled",
|
||||
delay: 5000
|
||||
timeout: 5000
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user