better session handling

- separated from component
- handle visibilityState / closing of the tab

Signed-off-by: chandi Langecker <git@chandi.it>
This commit is contained in:
chandi Langecker
2022-09-05 11:53:13 +02:00
parent 6bfb54e2b3
commit 38aed97d69
7 changed files with 143 additions and 98 deletions

View File

@@ -40,6 +40,18 @@ export class SessionApi {
return await axios.post(this.url('/session/close'), { boardId, token })
}
async closeSessionViaBeacon(boardId, token) {
const body = {
boardId,
token,
}
const headers = {
type: 'application/json',
}
const blob = new Blob([JSON.stringify(body)], headers)
navigator.sendBeacon(this.url('/session/close'), blob)
}
}
export const sessionApi = new SessionApi()