snapdrop

A Progressive Web App for local file sharing
git clone http://git.hanabi.in/repos/snapdrop.git
Log | Files | Refs | README | LICENSE

commit c68a7ad987a4b99c72213052711e9c197d0c3f40
parent 16b64a98ccb1cec0528e238dfb2b2d151ead320c
Author: RobinLinus <robinlinus@users.noreply.github.com>
Date:   Tue, 12 Mar 2019 23:37:50 +0100

Show a basic notification when user is offline

Diffstat:
Mclient/scripts/ui.js | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/client/scripts/ui.js b/client/scripts/ui.js @@ -414,6 +414,25 @@ class Notifications { } } + +class NetworkStatusUI{ + + constructor() { + window.addEventListener('offline', e => this._showOfflineMessage(), false); + window.addEventListener('online', e => this._showOnlineMessage(), false); + if(!navigator.onLine) this._showOfflineMessage(); + } + + _showOfflineMessage(){ + Events.fire('notify-user','You are offline'); + } + + _showOnlineMessage(){ + Events.fire('notify-user','You are back online'); + } +} + + class Snapdrop { constructor() { const server = new ServerConnection(); @@ -425,6 +444,7 @@ class Snapdrop { const receiveTextDialog = new ReceiveTextDialog(); const toast = new Toast(); const notifications = new Notifications(); + const networkStatusUI = new NetworkStatusUI(); }) } }