mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-21 07:16:18 -04:00
Notfication API on android
This commit is contained in:
parent
3601ace829
commit
390c72c933
3 changed files with 10 additions and 3 deletions
|
@ -9,7 +9,8 @@ class ServerConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
_connect() {
|
_connect() {
|
||||||
if (this._isConnected()) return;
|
clearTimeout(this._reconnectTimer);
|
||||||
|
if (this._isConnected() || this._isConnecting()) return;
|
||||||
const ws = new WebSocket(this._endpoint());
|
const ws = new WebSocket(this._endpoint());
|
||||||
ws.binaryType = 'arraybuffer';
|
ws.binaryType = 'arraybuffer';
|
||||||
ws.onopen = e => console.log('WS: server connected');
|
ws.onopen = e => console.log('WS: server connected');
|
||||||
|
@ -17,13 +18,16 @@ class ServerConnection {
|
||||||
ws.onclose = e => this._onDisconnect();
|
ws.onclose = e => this._onDisconnect();
|
||||||
ws.onerror = e => console.error(e);
|
ws.onerror = e => console.error(e);
|
||||||
this._socket = ws;
|
this._socket = ws;
|
||||||
clearTimeout(this._reconnectTimer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_isConnected() {
|
_isConnected() {
|
||||||
return this._socket && this._socket.readyState === this._socket.OPEN;
|
return this._socket && this._socket.readyState === this._socket.OPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isConnecting() {
|
||||||
|
return this._socket && this._socket.readyState === this._socket.CONNECTING;
|
||||||
|
}
|
||||||
|
|
||||||
_onMessage(msg) {
|
_onMessage(msg) {
|
||||||
msg = JSON.parse(msg);
|
msg = JSON.parse(msg);
|
||||||
console.log('WS:', msg);
|
console.log('WS:', msg);
|
||||||
|
|
|
@ -361,7 +361,8 @@ class Notifications {
|
||||||
const config = {
|
const config = {
|
||||||
body: body,
|
body: body,
|
||||||
icon: '/images/logo_transparent_128x128.png',
|
icon: '/images/logo_transparent_128x128.png',
|
||||||
vibrate: [200, 100, 200, 100, 200, 100, 400],
|
// vibrate: [200, 100, 200, 100, 200, 100, 400],
|
||||||
|
// requireInteraction: true
|
||||||
}
|
}
|
||||||
if (serviceWorker && serviceWorker.showNotification) {
|
if (serviceWorker && serviceWorker.showNotification) {
|
||||||
// android doesn't support "new Notification" if service worker is installed
|
// android doesn't support "new Notification" if service worker is installed
|
||||||
|
|
|
@ -301,6 +301,7 @@ x-dialog x-background {
|
||||||
background: rgba(0, 0, 0, 0.61);
|
background: rgba(0, 0, 0, 0.61);
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
transition: opacity 300ms;
|
transition: opacity 300ms;
|
||||||
|
will-change: opacity;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +314,7 @@ x-dialog x-paper {
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
transition: transform 300ms;
|
transition: transform 300ms;
|
||||||
|
will-change: transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
x-dialog:not([show]) {
|
x-dialog:not([show]) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue