factor out setLastSeenApp()

This commit is contained in:
Daniel Lugo 2020-04-18 14:37:16 -04:00
parent 0116d817ef
commit d5b9a23356

View file

@ -441,23 +441,7 @@ class Mediator {
this.socket.on(IS_GUN_AUTH, this.isGunAuth)
this.socket.on(Action.SET_LAST_SEEN_APP, async body => {
try {
await throwOnInvalidToken(body.token)
await API.Actions.setLastSeenApp()
this.socket.emit(Action.SET_LAST_SEEN_APP, {
ok: true,
msg: null,
origBody: body
})
} catch (e) {
this.socket.emit(Action.SET_LAST_SEEN_APP, {
ok: false,
msg: e.message,
origBody: body
})
}
})
this.socket.on(Action.SET_LAST_SEEN_APP, this.setLastSeenApp)
}
/** @param {SimpleSocket} socket */
@ -543,6 +527,25 @@ class Mediator {
}
}
/** @param {{ token: string }} body */
setLastSeenApp = async body => {
try {
await throwOnInvalidToken(body.token)
await API.Actions.setLastSeenApp()
this.socket.emit(Action.SET_LAST_SEEN_APP, {
ok: true,
msg: null,
origBody: body
})
} catch (e) {
this.socket.emit(Action.SET_LAST_SEEN_APP, {
ok: false,
msg: e.message,
origBody: body
})
}
}
isGunAuth = () => {
try {
const isGunAuth = isAuthenticated()