Browse Source

handling for 'invalid bid' error

pull/182/head
DashEightMate 7 months ago
parent
commit
62f8deba93
  1. 13
      src/services/WebSocketService.ts
  2. 15
      src/utils.ts

13
src/services/WebSocketService.ts

@ -91,10 +91,15 @@ export class WebSocketService {
this.ws.onmessage = e => {
try {
let json = JSON.parse(e.data);
if (json.error && json.error.includes('site_ban')) {
const id = json.error.replace('site_ban_', '');
json.error = 'site_ban';
localStorage.setItem('bid', id);
if (json.error) {
if (json.error.includes('site_ban')) {
const id = json.error.replace('site_ban_', '');
json.error = 'site_ban';
localStorage.setItem('bid', id);
} else if (json.error === 'invalid_bid') {
localStorage.removeItem('bid');
window.location.reload();
}
}
obs.next(json);
} catch (error) {

15
src/utils.ts

@ -1243,10 +1243,17 @@ export const api = axios.create({
});
api.interceptors.response.use(undefined, error => {
if (error.response && error.response.data.error.includes('site_ban')) {
const id = error.response.data.error.replace('site_ban_', '');
error.response.data.error = 'site_ban';
localStorage.setItem('bid', id);
if (error.response) {
const errName = error.response.data.error;
if (errName.includes('site_ban')) {
const id = errName.replace('site_ban_', '');
error.response.data.error = 'site_ban';
localStorage.setItem('bid', id);
} else if (errName === 'invalid_bid') {
//remove bid and retry request
localStorage.removeItem('bid');
return axios.request(error.config);
}
}
return Promise.reject(error);
});

Loading…
Cancel
Save