1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-13 09:15:47 +02:00

Add a network error notification if the device goes offline

Closes 
This commit is contained in:
chylex 2017-08-28 22:14:07 +02:00
parent 8c0d306823
commit cd87a329fc

View File

@ -952,6 +952,44 @@
};
}
//
// Block: Detect and notify about connection issues.
//
(function(){
let onConnectionError = function(){
return if $("#tweetduck-conn-issues").length;
let ele = $(`
<div id="tweetduck-conn-issues" class="Layer NotificationListLayer">
<ul class="NotificationList">
<li class="Notification Notification--red" style="height:63px;">
<div class="Notification-inner">
<div class="Notification-icon"><span class="Icon Icon--medium Icon--circleError"></span></div>
<div class="Notification-content"><div class="Notification-body">Experiencing connection issues</div></div>
<button type="button" class="Notification-closeButton" aria-label="Close"><span class="Icon Icon--smallest Icon--close" aria-hidden="true"></span></button>
</div>
</li>
</ul>
</div>
`).appendTo(document.body);
ele.find("button").click(function(){
ele.fadeOut(200);
});
};
let onConnectionFine = function(){
let ele = $("#tweetduck-conn-issues");
ele.fadeOut(200, function(){
ele.remove();
});
};
window.addEventListener("offline", onConnectionError);
window.addEventListener("online", onConnectionFine);
})();
//
// Block: Custom reload function with memory cleanup.
//