mirror of
https://github.com/janishutz/MusicPlayerV2.git
synced 2025-11-25 13:04:23 +00:00
fix reconnecting function (stop it from spamming)
This commit is contained in:
@@ -651,15 +651,16 @@ const app = Vue.createApp( {
|
|||||||
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
||||||
|
|
||||||
if ( e.target.readyState == EventSource.CLOSED ) {
|
if ( e.target.readyState == EventSource.CLOSED ) {
|
||||||
console.log( 'disconnected' );
|
setTimeout( () => {
|
||||||
|
if ( !self.isReconnecting ) {
|
||||||
|
console.log( 'disconnected' );
|
||||||
|
console.log( 'reconnecting...' );
|
||||||
|
self.isReconnecting = true;
|
||||||
|
self.tryReconnect();
|
||||||
|
}
|
||||||
|
}, 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout( () => {
|
|
||||||
if ( !self.isReconnecting ) {
|
|
||||||
self.isReconnecting = true;
|
|
||||||
self.tryReconnect();
|
|
||||||
}
|
|
||||||
}, 1000 );
|
|
||||||
}, false );
|
}, false );
|
||||||
},
|
},
|
||||||
tryReconnect() {
|
tryReconnect() {
|
||||||
@@ -667,7 +668,7 @@ const app = Vue.createApp( {
|
|||||||
if ( !this.isReconnecting ) {
|
if ( !this.isReconnecting ) {
|
||||||
clearInterval( int );
|
clearInterval( int );
|
||||||
} else {
|
} else {
|
||||||
connectToSSESource();
|
this.connectToNotifier();
|
||||||
}
|
}
|
||||||
}, 1000 );
|
}, 1000 );
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ createApp( {
|
|||||||
beatDetected: false,
|
beatDetected: false,
|
||||||
colorThief: null,
|
colorThief: null,
|
||||||
lastDispatch: new Date().getTime() - 5000,
|
lastDispatch: new Date().getTime() - 5000,
|
||||||
|
isReconnecting: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -148,16 +149,14 @@ createApp( {
|
|||||||
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
||||||
|
|
||||||
if ( e.target.readyState == EventSource.CLOSED ) {
|
if ( e.target.readyState == EventSource.CLOSED ) {
|
||||||
console.log( 'disconnected' );
|
setTimeout( () => {
|
||||||
|
if ( !self.isReconnecting ) {
|
||||||
|
console.log( 'disconnected' );
|
||||||
|
self.isReconnecting = true;
|
||||||
|
self.tryReconnect();
|
||||||
|
}
|
||||||
|
}, 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Notify about disconnect
|
|
||||||
setTimeout( () => {
|
|
||||||
if ( !self.isReconnecting ) {
|
|
||||||
self.isReconnecting = true;
|
|
||||||
self.tryReconnect();
|
|
||||||
}
|
|
||||||
}, 1000 );
|
|
||||||
}, false );
|
}, false );
|
||||||
},
|
},
|
||||||
tryReconnect() {
|
tryReconnect() {
|
||||||
@@ -165,7 +164,7 @@ createApp( {
|
|||||||
if ( !this.isReconnecting ) {
|
if ( !this.isReconnecting ) {
|
||||||
clearInterval( int );
|
clearInterval( int );
|
||||||
} else {
|
} else {
|
||||||
connectToSSESource();
|
this.connect();
|
||||||
}
|
}
|
||||||
}, 1000 );
|
}, 1000 );
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user