mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-22 07:46:17 -04:00
Make user notifications and document titles more concise.
This commit is contained in:
parent
bfb5aa8546
commit
bb0493d071
4 changed files with 24 additions and 20 deletions
|
@ -36,6 +36,7 @@ class ServerConnection {
|
||||||
_onOpen() {
|
_onOpen() {
|
||||||
console.log('WS: server connected');
|
console.log('WS: server connected');
|
||||||
Events.fire('ws-connected');
|
Events.fire('ws-connected');
|
||||||
|
if (this._isReconnect) Events.fire('notify-user', 'Connected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendRoomSecrets(roomSecrets) {
|
_sendRoomSecrets(roomSecrets) {
|
||||||
|
@ -145,15 +146,17 @@ class ServerConnection {
|
||||||
this._socket.close();
|
this._socket.close();
|
||||||
this._socket = null;
|
this._socket = null;
|
||||||
Events.fire('ws-disconnected');
|
Events.fire('ws-disconnected');
|
||||||
|
this._isReconnect = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDisconnect() {
|
_onDisconnect() {
|
||||||
console.log('WS: server disconnected');
|
console.log('WS: server disconnected');
|
||||||
Events.fire('notify-user', 'No server connection. Retry in 5s...');
|
Events.fire('notify-user', 'Connecting..');
|
||||||
clearTimeout(this._reconnectTimer);
|
clearTimeout(this._reconnectTimer);
|
||||||
this._reconnectTimer = setTimeout(_ => this._connect(), 5000);
|
this._reconnectTimer = setTimeout(_ => this._connect(), 5000);
|
||||||
Events.fire('ws-disconnected');
|
Events.fire('ws-disconnected');
|
||||||
|
this._isReconnect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onVisibilityChange() {
|
_onVisibilityChange() {
|
||||||
|
|
|
@ -662,7 +662,7 @@ class ReceiveFileDialog extends ReceiveDialog {
|
||||||
this.createPreviewElement(files[0]).finally(_ => {
|
this.createPreviewElement(files[0]).finally(_ => {
|
||||||
document.title = files.length === 1
|
document.title = files.length === 1
|
||||||
? 'File received - PairDrop'
|
? 'File received - PairDrop'
|
||||||
: `(${files.length}) Files received - PairDrop`;
|
: `${files.length} Files received - PairDrop`;
|
||||||
document.changeFavicon("images/favicon-96x96-notification.png");
|
document.changeFavicon("images/favicon-96x96-notification.png");
|
||||||
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
|
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
|
||||||
this.show();
|
this.show();
|
||||||
|
@ -1143,7 +1143,7 @@ class ReceiveTextDialog extends Dialog {
|
||||||
_setDocumentTitleMessages() {
|
_setDocumentTitleMessages() {
|
||||||
document.title = !this._receiveTextQueue.length
|
document.title = !this._receiveTextQueue.length
|
||||||
? 'Message Received - PairDrop'
|
? 'Message Received - PairDrop'
|
||||||
: `(${this._receiveTextQueue.length + 1}) Messages Received - PairDrop`;
|
: `${this._receiveTextQueue.length + 1} Messages Received - PairDrop`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onCopy() {
|
async _onCopy() {
|
||||||
|
@ -1424,7 +1424,7 @@ class NetworkStatusUI {
|
||||||
constructor() {
|
constructor() {
|
||||||
Events.on('offline', _ => this._showOfflineMessage());
|
Events.on('offline', _ => this._showOfflineMessage());
|
||||||
Events.on('online', _ => this._showOnlineMessage());
|
Events.on('online', _ => this._showOnlineMessage());
|
||||||
Events.on('ws-connected', _ => this._showOnlineMessage());
|
Events.on('ws-connected', _ => this._onWsConnected());
|
||||||
Events.on('ws-disconnected', _ => this._onWsDisconnected());
|
Events.on('ws-disconnected', _ => this._onWsDisconnected());
|
||||||
if (!navigator.onLine) this._showOfflineMessage();
|
if (!navigator.onLine) this._showOfflineMessage();
|
||||||
}
|
}
|
||||||
|
@ -1435,17 +1435,16 @@ class NetworkStatusUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
_showOnlineMessage() {
|
_showOnlineMessage() {
|
||||||
window.animateBackground(true);
|
|
||||||
if (!this.firstConnect) {
|
|
||||||
this.firstConnect = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Events.fire('notify-user', 'You are back online');
|
Events.fire('notify-user', 'You are back online');
|
||||||
|
window.animateBackground(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
_onWsConnected() {
|
||||||
|
window.animateBackground(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onWsDisconnected() {
|
_onWsDisconnected() {
|
||||||
window.animateBackground(false);
|
window.animateBackground(false);
|
||||||
if (!this.firstConnect) this.firstConnect = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ class ServerConnection {
|
||||||
_onOpen() {
|
_onOpen() {
|
||||||
console.log('WS: server connected');
|
console.log('WS: server connected');
|
||||||
Events.fire('ws-connected');
|
Events.fire('ws-connected');
|
||||||
|
if (this._isReconnect) Events.fire('notify-user', 'Connected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendRoomSecrets(roomSecrets) {
|
_sendRoomSecrets(roomSecrets) {
|
||||||
|
@ -155,15 +156,17 @@ class ServerConnection {
|
||||||
this._socket.close();
|
this._socket.close();
|
||||||
this._socket = null;
|
this._socket = null;
|
||||||
Events.fire('ws-disconnected');
|
Events.fire('ws-disconnected');
|
||||||
|
this._isReconnect = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDisconnect() {
|
_onDisconnect() {
|
||||||
console.log('WS: server disconnected');
|
console.log('WS: server disconnected');
|
||||||
Events.fire('notify-user', 'No server connection. Retry in 5s...');
|
Events.fire('notify-user', 'Connecting..');
|
||||||
clearTimeout(this._reconnectTimer);
|
clearTimeout(this._reconnectTimer);
|
||||||
this._reconnectTimer = setTimeout(_ => this._connect(), 5000);
|
this._reconnectTimer = setTimeout(_ => this._connect(), 5000);
|
||||||
Events.fire('ws-disconnected');
|
Events.fire('ws-disconnected');
|
||||||
|
this._isReconnect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onVisibilityChange() {
|
_onVisibilityChange() {
|
||||||
|
|
|
@ -663,7 +663,7 @@ class ReceiveFileDialog extends ReceiveDialog {
|
||||||
this.createPreviewElement(files[0]).finally(_ => {
|
this.createPreviewElement(files[0]).finally(_ => {
|
||||||
document.title = files.length === 1
|
document.title = files.length === 1
|
||||||
? 'File received - PairDrop'
|
? 'File received - PairDrop'
|
||||||
: `(${files.length}) Files received - PairDrop`;
|
: `${files.length} Files received - PairDrop`;
|
||||||
document.changeFavicon("images/favicon-96x96-notification.png");
|
document.changeFavicon("images/favicon-96x96-notification.png");
|
||||||
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
|
Events.fire('set-progress', {peerId: peerId, progress: 1, status: 'process'})
|
||||||
this.show();
|
this.show();
|
||||||
|
@ -1144,7 +1144,7 @@ class ReceiveTextDialog extends Dialog {
|
||||||
_setDocumentTitleMessages() {
|
_setDocumentTitleMessages() {
|
||||||
document.title = !this._receiveTextQueue.length
|
document.title = !this._receiveTextQueue.length
|
||||||
? 'Message Received - PairDrop'
|
? 'Message Received - PairDrop'
|
||||||
: `(${this._receiveTextQueue.length + 1}) Messages Received - PairDrop`;
|
: `${this._receiveTextQueue.length + 1} Messages Received - PairDrop`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onCopy() {
|
async _onCopy() {
|
||||||
|
@ -1425,7 +1425,7 @@ class NetworkStatusUI {
|
||||||
constructor() {
|
constructor() {
|
||||||
Events.on('offline', _ => this._showOfflineMessage());
|
Events.on('offline', _ => this._showOfflineMessage());
|
||||||
Events.on('online', _ => this._showOnlineMessage());
|
Events.on('online', _ => this._showOnlineMessage());
|
||||||
Events.on('ws-connected', _ => this._showOnlineMessage());
|
Events.on('ws-connected', _ => this._onWsConnected());
|
||||||
Events.on('ws-disconnected', _ => this._onWsDisconnected());
|
Events.on('ws-disconnected', _ => this._onWsDisconnected());
|
||||||
if (!navigator.onLine) this._showOfflineMessage();
|
if (!navigator.onLine) this._showOfflineMessage();
|
||||||
}
|
}
|
||||||
|
@ -1436,17 +1436,16 @@ class NetworkStatusUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
_showOnlineMessage() {
|
_showOnlineMessage() {
|
||||||
window.animateBackground(true);
|
|
||||||
if (!this.firstConnect) {
|
|
||||||
this.firstConnect = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Events.fire('notify-user', 'You are back online');
|
Events.fire('notify-user', 'You are back online');
|
||||||
|
window.animateBackground(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
_onWsConnected() {
|
||||||
|
window.animateBackground(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onWsDisconnected() {
|
_onWsDisconnected() {
|
||||||
window.animateBackground(false);
|
window.animateBackground(false);
|
||||||
if (!this.firstConnect) this.firstConnect = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue