diff --git a/src/client/app/ipc/index.js b/src/client/app/ipc/index.js index f1295ce7..6a3f82f4 100644 --- a/src/client/app/ipc/index.js +++ b/src/client/app/ipc/index.js @@ -66,6 +66,12 @@ class Ipc extends EventEmitter { }, hearbeatTimeout) }, hearbeatInterval) + if (notifications) notifications.add({ + icon: 'wifi', + message: locales('server_connected'), + id: 'ipc_state' + }) + this.trigger('connect') this.flush() @@ -88,7 +94,13 @@ class Ipc extends EventEmitter { this.hearbeat = clearInterval(this.hearbeat) this.hearbeatTimeout = clearTimeout(this.hearbeatTimeout) this.dieTimeout = clearTimeout(this.dieTimeout) - + notifications.add({ + icon: 'wifi', + class: 'error', + message: locales('server_disconnected'), + id: 'ipc_state', + duration: Infinity + }) if (!this.reconnect) { this.reconnect = setInterval(()=>{ this.open() @@ -127,12 +139,6 @@ class Ipc extends EventEmitter { this.socket.send(packet) } else { this.queue.push(packet) - notifications.add({ - icon: 'wifi', - class: 'error', - message: locales('server_unreachable'), - id: 'server_unreachable' - }) } } diff --git a/src/client/app/locales/en.js b/src/client/app/locales/en.js index 0fb88864..52a43128 100644 --- a/src/client/app/locales/en.js +++ b/src/client/app/locales/en.js @@ -32,7 +32,8 @@ module.exports = { fs_addtohome: 'You must add this page to your home screen to launch it in fullscreen', // server - server_unreachable: 'The server is currently unreachable', + server_disconnected: 'The connection to the server has been interrupted', + server_connected: 'The connection to the server has been restored', // session session_browse: 'Browse...', diff --git a/src/client/app/locales/fr.js b/src/client/app/locales/fr.js index a7107b48..794d8c44 100644 --- a/src/client/app/locales/fr.js +++ b/src/client/app/locales/fr.js @@ -32,7 +32,8 @@ module.exports = { fs_addtohome: 'Vous devez ajouter cette page à votre écran d\'accueil pour pouvoir l\'ouvrir en plein écran.', // server - server_unreachable: 'La connexion avec le serveur a été interrompue', + server_disconnected: 'La connexion avec le serveur a été interrompue', + server_connected: 'La connexion avec le serveur a été rétablie', // session session_browse: 'Parcourir...', diff --git a/src/client/app/locales/ru.js b/src/client/app/locales/ru.js index 9ef05488..81d6f3ba 100644 --- a/src/client/app/locales/ru.js +++ b/src/client/app/locales/ru.js @@ -32,8 +32,9 @@ module.exports = { // @https://github.com/suhr fs_addtohome: 'Необходимо добавить эту страницу на главный экран чтобы запустить её в полноэкранном режиме', // server - server_unreachable: 'The server is currently unreachable', - + server_disconnected: 'The connection to the server has been interrupted', + server_connected: 'The connection to the server has been restored', + // session session_browse: 'Обзор...', session_new: 'Новая сессия', diff --git a/src/client/app/ui/notifications.js b/src/client/app/ui/notifications.js index 2e1bdce6..d8eb16ed 100644 --- a/src/client/app/ui/notifications.js +++ b/src/client/app/ui/notifications.js @@ -1,6 +1,55 @@ -var html = require('nanohtml') +var html = require('nanohtml'), + morph = require('nanomorph') -var DURATION = 3500 + +var DEFAULT_DURATION = 3500 + +class Toast { + + constructor(data) { + + this.id = data.id || Date.now() + this.update(data) + + } + + update(data) { + + this.expires = Date.now() + (data.duration || DEFAULT_DURATION) + + var html = html` +