aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2021-02-09 12:00:32 +0100
committerJakob Stendahl <jakob.stendahl@outlook.com>2021-02-09 12:00:32 +0100
commit7c6ed24a06b4f7303ea8fa9abb1d51d2bb9f125d (patch)
tree88e5be35a0344295e8878471fa288c5b6141d31d /src
parent1c705d5c6fcbc28cd17dfdd167d9b1b57920158d (diff)
downloadhoverbit-ble-7c6ed24a06b4f7303ea8fa9abb1d51d2bb9f125d.tar.gz
hoverbit-ble-7c6ed24a06b4f7303ea8fa9abb1d51d2bb9f125d.zip
:bug: Make notifications wait to be displayed until they actually will show
Diffstat (limited to 'src')
-rw-r--r--src/js/notification.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/js/notification.js b/src/js/notification.js
index c2eb14c..7f36895 100644
--- a/src/js/notification.js
+++ b/src/js/notification.js
@@ -1,9 +1,23 @@
+let waiting_timer = undefined;
let notif_queue = [];
function notif(notif_c) {
let notification_area = document.querySelector(".statusline .notification-area");
- if (notification_area.querySelector(".notification") === null) {
+ if ((notification_area.querySelector(".notification") === null) && (waiting_timer === undefined)) {
+ // This is just so no notifications will be played and disappears while the full screen landscape warning is in the way.
+ if( (screen.availHeight > screen.availWidth) && (!document.body.classList.contains("ignore-landscape-warning"))){
+ waiting_timer = setInterval(() => {
+ if( (screen.availHeight < screen.availWidth) || (document.body.classList.contains("ignore-landscape-warning"))){
+ clearInterval(waiting_timer);
+ waiting_timer = undefined;
+ notif(notif_queue.pop());
+ }
+ }, 1000);
+ notif_queue.push(notif_c);
+ return;
+ }
+
let notif_elem = document.createElement("div");
notif_elem.className = "notification";
notif_elem.appendChild(notif_c[0]);