Fixed TS errors and formatted with Prettier
This commit is contained in:
parent
cbf8bdbadc
commit
3d377e6c69
4 changed files with 51 additions and 39 deletions
|
|
@ -27,14 +27,15 @@ const on = (cb, pub) => {
|
|||
listeners.add(cb)
|
||||
cb(pubToLastSeenApp)
|
||||
if (pub && pubsWithListeners.add(pub)) {
|
||||
pubToLastSeenApp[pub] = null;
|
||||
pubToLastSeenApp[pub] = null
|
||||
notifyListeners()
|
||||
require('../../Mediator')
|
||||
.getGun()
|
||||
.user(pub)
|
||||
.get(Key.LAST_SEEN_APP)
|
||||
.on(timestamp => {
|
||||
pubToLastSeenApp[pub] = typeof timestamp === 'number' ? timestamp : undefined
|
||||
pubToLastSeenApp[pub] =
|
||||
typeof timestamp === 'number' ? timestamp : undefined
|
||||
notifyListeners()
|
||||
})
|
||||
}
|
||||
|
|
@ -45,5 +46,5 @@ const on = (cb, pub) => {
|
|||
|
||||
module.exports = {
|
||||
getPubToLastSeenApp,
|
||||
on,
|
||||
}
|
||||
on
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,10 +179,12 @@ const startSocket = socket => {
|
|||
}
|
||||
|
||||
if (isAuthenticated()) {
|
||||
socket.onAny(() => {
|
||||
GunActions.setLastSeenApp().catch(e =>
|
||||
logger.info('error setting last seen app', e)
|
||||
)
|
||||
socket.onAny(async () => {
|
||||
try {
|
||||
await GunActions.setLastSeenApp()
|
||||
} catch (err) {
|
||||
logger.info('error setting last seen app', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,7 @@ const add = ({ deviceId, subscriptionId, unsubscribe, metadata }) => {
|
|||
* @param {string} subscription.subscriptionId
|
||||
* @param {Unsubscribe} subscription.unsubscribe
|
||||
*/
|
||||
const attachUnsubscribe = ({
|
||||
deviceId,
|
||||
subscriptionId,
|
||||
unsubscribe
|
||||
}) => {
|
||||
const attachUnsubscribe = ({ deviceId, subscriptionId, unsubscribe }) => {
|
||||
const deviceSubscriptions = userSubscriptions.get(deviceId)
|
||||
|
||||
const subscriptions = deviceSubscriptions
|
||||
|
|
@ -68,7 +64,7 @@ const remove = ({ deviceId, subscriptionId }) => {
|
|||
const deviceSubscriptions = userSubscriptions.get(deviceId)
|
||||
|
||||
const subscriptions = deviceSubscriptions ?? new Map()
|
||||
const subscription = subscriptions.get(subscriptionId);
|
||||
const subscription = subscriptions.get(subscriptionId)
|
||||
|
||||
if (subscription?.unsubscribe) {
|
||||
subscription.unsubscribe()
|
||||
|
|
@ -84,7 +80,7 @@ const remove = ({ deviceId, subscriptionId }) => {
|
|||
* @param {string} subscription.deviceId
|
||||
*/
|
||||
const removeDevice = ({ deviceId }) => {
|
||||
const deviceSubscriptions = userSubscriptions.get(deviceId);
|
||||
const deviceSubscriptions = userSubscriptions.get(deviceId)
|
||||
|
||||
if (!deviceSubscriptions) {
|
||||
return
|
||||
|
|
@ -98,7 +94,7 @@ const removeDevice = ({ deviceId }) => {
|
|||
return subscription
|
||||
})
|
||||
|
||||
userSubscriptions.set(deviceId, new Map());
|
||||
userSubscriptions.set(deviceId, new Map())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -124,4 +120,4 @@ module.exports = {
|
|||
get,
|
||||
remove,
|
||||
removeDevice
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
module.exports = {
|
||||
unprotectedRoutes: {
|
||||
GET: {
|
||||
"/healthz": true,
|
||||
"/ping": true,
|
||||
"/tunnel/status": true,
|
||||
'/healthz': true,
|
||||
'/ping': true,
|
||||
'/tunnel/status': true,
|
||||
// Errors out when viewing an API page from the browser
|
||||
"/favicon.ico": true,
|
||||
"/api/lnd/connect": true,
|
||||
"/api/lnd/wallet/status": true,
|
||||
"/api/lnd/auth": true,
|
||||
'/favicon.ico': true,
|
||||
'/api/lnd/connect': true,
|
||||
'/api/lnd/wallet/status': true,
|
||||
'/api/lnd/auth': true,
|
||||
//
|
||||
"/api/gun/auth": true,
|
||||
"/api/subscribeStream":true,
|
||||
"/":true,
|
||||
"/api/accessInfo":true,
|
||||
"/qrCodeGenerator":true,
|
||||
'/api/gun/auth': true,
|
||||
'/api/subscribeStream': true,
|
||||
'/': true,
|
||||
'/api/accessInfo': true,
|
||||
'/qrCodeGenerator': true
|
||||
},
|
||||
POST: {
|
||||
"/api/lnd/connect": true,
|
||||
"/api/lnd/wallet": true,
|
||||
"/api/lnd/wallet/existing": true,
|
||||
"/api/lnd/auth": true,
|
||||
"/api/security/exchangeKeys": true,
|
||||
"/api/encryption/exchange": true
|
||||
'/api/lnd/connect': true,
|
||||
'/api/lnd/wallet': true,
|
||||
'/api/lnd/wallet/existing': true,
|
||||
'/api/lnd/auth': true,
|
||||
'/api/security/exchangeKeys': true,
|
||||
'/api/encryption/exchange': true
|
||||
},
|
||||
PUT: {},
|
||||
DELETE: {},
|
||||
|
|
@ -39,11 +39,24 @@ module.exports = {
|
|||
sensitiveRoutes: {
|
||||
GET: {},
|
||||
POST: {
|
||||
"/api/lnd/connect": true,
|
||||
"/api/lnd/wallet": true
|
||||
'/api/lnd/connect': true,
|
||||
'/api/lnd/wallet': true
|
||||
},
|
||||
PUT: {},
|
||||
DELETE: {}
|
||||
},
|
||||
nonEncryptedRoutes: ['/api/security/exchangeKeys', "/api/encryption/exchange", '/healthz', '/ping', '/tunnel/status', '/api/lnd/wallet/status', '/api/gun/auth',"/api/subscribeStream", "/", "/api/accessInfo","/qrCodeGenerator"]
|
||||
}
|
||||
nonEncryptedRoutes: [
|
||||
'/api/security/exchangeKeys',
|
||||
'/api/encryption/exchange',
|
||||
'/healthz',
|
||||
'/ping',
|
||||
'/tunnel/status',
|
||||
'/api/lnd/wallet/status',
|
||||
'/api/gun/auth',
|
||||
'/api/subscribeStream',
|
||||
'/',
|
||||
'/api/accessInfo',
|
||||
'/qrCodeGenerator',
|
||||
'/gun'
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue