From a3aba8d0db660284ca6ea6509bedf1893b3ed265 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 5 Sep 2025 22:29:20 +0200 Subject: [PATCH] Toast: update visibility for newest toast --- Services/ToastService.qml | 21 ++++++++++++--------- Widgets/NToast.qml | 9 +++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Services/ToastService.qml b/Services/ToastService.qml index 6c0be38..edff04b 100644 --- a/Services/ToastService.qml +++ b/Services/ToastService.qml @@ -165,13 +165,21 @@ Singleton { "timestamp": Date.now() } + // If there's already a toast showing, instantly start hide animation and show new one + if (isShowingToast) { + // Instantly start hide animation of current toast + for (var i = 0; i < allToasts.length; i++) { + allToasts[i].hide() + } + // Clear the queue since we're showing the new toast immediately + messageQueue = [] + } + // Add to queue messageQueue.push(toastData) - // Process queue if not currently showing a toast - if (!isShowingToast) { - processQueue() - } + // Always process immediately for instant display + processQueue() } // Process the message queue @@ -181,11 +189,6 @@ Singleton { return } - if (isShowingToast) { - // Wait for current toast to finish - return - } - var toastData = messageQueue.shift() isShowingToast = true diff --git a/Widgets/NToast.qml b/Widgets/NToast.qml index 44a0bb5..079bd3c 100644 --- a/Widgets/NToast.qml +++ b/Widgets/NToast.qml @@ -37,7 +37,16 @@ Item { // NToast updates its scaling when showing. scaling = ScalingService.getScreenScale(screen) + // Stop any running animations and reset state + showAnimation.stop() + hideAnimation.stop() + autoHideTimer.stop() + + // Ensure we start from the hidden position + y = hiddenY visible = true + + // Start the show animation showAnimation.start() if (duration > 0 && !persistent) { autoHideTimer.start()