Fix some errors, style updates

This commit is contained in:
2025-11-22 22:37:36 +01:00
parent e0dcfa6964
commit 576b6f9490
8 changed files with 173 additions and 23 deletions

View File

@@ -8,7 +8,10 @@
<!-- TODO: Make prettier -->
</div>
<div v-else-if="!$props.isLoggedIn" class="not-logged-in">
<p>You are not logged into Apple Music. We therefore can't show you your playlists. <a href="" title="Refreshes the page, allowing you to log in">Change that</a></p>
<p>
You are not logged into Apple Music. We therefore can't show you your playlists.
<a href="" title="Refreshes the page, allowing you to log in">Change that</a>
</p>
<p>Use the button below to load songs from your local disk</p>
<input
id="pl-loader"

View File

@@ -1,7 +1,7 @@
// These functions handle connections to the backend with socket.io
import {
io, type Socket
type Socket, io
} from 'socket.io-client';
import type {
SSEMap

View File

@@ -1,7 +1,7 @@
// These functions handle connections to the backend with socket.io
import {
io, type Socket
type Socket, io
} from 'socket.io-client';
import type {
SSEMap
@@ -57,7 +57,8 @@ class NotificationHandler {
*/
connect ( roomName: string, useAntiTamper: boolean ): Promise<void> {
return new Promise( ( resolve, reject ) => {
fetch( localStorage.getItem( 'url' ) + '/createRoomToken?roomName=' + roomName + '&useAntiTamper=' + useAntiTamper, {
fetch( localStorage.getItem( 'url' ) + '/createRoomToken?roomName='
+ roomName + '&useAntiTamper=' + useAntiTamper, {
'credentials': 'include'
} ).then( res => {
if ( res.status === 200 ) {
@@ -110,7 +111,8 @@ class NotificationHandler {
'credentials': 'include'
} ).then( res => {
if ( res.status === 200 ) {
this.eventSource = new EventSource( localStorage.getItem( 'url' ) + '/socket/connection?room=' + this.roomName, {
this.eventSource = new EventSource( localStorage.getItem( 'url' )
+ '/socket/connection?room=' + this.roomName, {
'withCredentials': true
} );
@@ -118,7 +120,8 @@ class NotificationHandler {
this.isConnected = true;
this.connectionWasSuccessful = true;
this.reconnectRetryCount = 0;
console.log( '[ SSE Connection ] - ' + new Date().toISOString() + ': Connection successfully established!' );
console.log( '[ SSE Connection ] - '
+ new Date().toISOString() + ': Connection successfully established!' );
resolve();
};
@@ -135,8 +138,10 @@ class NotificationHandler {
this.isConnected = false;
this.eventSource?.close();
this.openConnectionsCount -= 1;
console.debug( e );
console.log( '[ SSE Connection ] - ' + new Date().toISOString() + ': Reconnecting due to connection error!' );
console.debug( '[ SSE Connection ] - Error encountered: ', e );
console.log( '[ SSE Connection ] - '
+ new Date().toISOString()
+ ': Reconnecting due to connection error!' );
this.eventSource = undefined;
@@ -146,7 +151,8 @@ class NotificationHandler {
}, 1000 * this.reconnectRetryCount );
}
};
} else if ( res.status === 403 || res.status === 401 || res.status === 404 || res.status === 402 ) {
} else if ( res.status === 403 || res.status === 401
|| res.status === 404 || res.status === 402 ) {
document.dispatchEvent( new Event( 'musicplayer:autherror' ) );
reject( 'ERR_UNAUTHORIZED' );
} else {
@@ -158,7 +164,8 @@ class NotificationHandler {
reject( 'ERR_ROOM_CONNECTING' );
} else {
this.openConnectionsCount -= 1;
console.log( '[ SSE Connection ] - ' + new Date().toISOString() + ': Reconnecting due to severe connection error!' );
console.log( '[ SSE Connection ] - ' + new Date().toISOString()
+ ': Reconnecting due to severe connection error!' );
this.eventSource = undefined;