improved crash recovery

This commit is contained in:
2024-09-13 13:58:04 +02:00
parent 6cf9e72263
commit 372ebf1057
5 changed files with 59 additions and 9 deletions

View File

@@ -111,9 +111,24 @@
const roomName = ref( '' );
const isShowingWarning = ref( false );
let currentlyOpenPopup = '';
let logoutErrorNotification = -1;
const emits = defineEmits( [ 'playerStateChange' ] );
document.addEventListener( 'musicplayer:autherror', () => {
localStorage.setItem( 'close-tab', 'true' );
isConnectedToNotifier.value = false;
logoutErrorNotification = notifications.value.createNotification( 'You appear to have been logged out. Click to log in again!', 600, 'error', 'critical', '/', true );
} );
window.addEventListener( 'storage', () => {
if ( localStorage.getItem( 'login-ok' ) === 'true' ) {
notifications.value.cancelNotification( logoutErrorNotification );
notifications.value.createNotification( 'Logged in again. You will have to reconnect to the share!', 20, 'ok', 'normal' );
localStorage.removeItem( 'login-ok' );
}
} );
const playPause = () => {
isPlaying.value = !isPlaying.value;
if ( isPlaying.value ) {
@@ -588,6 +603,10 @@
if ( e === 'ERR_CONFLICT' ) {
notifications.value.createNotification( 'A share with this name exists already!', 5, 'error', 'normal' );
control( 'start-share' );
} else if ( e === 'ERR_UNAUTHORIZED' ) {
console.error( e );
localStorage.setItem( 'close-tab', 'true' );
logoutErrorNotification = notifications.value.createNotification( 'You appear to have been logged out. Click to log in again!', 20, 'error', 'normal', '/', true );
} else {
console.error( e );
notifications.value.createNotification( 'Could not create share!', 5, 'error', 'normal' );