mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-15 19:27:42 +08:00
no log: Restore socket.io dev command for better development
This commit is contained in:
parent
0fb928675c
commit
ee7991b878
3 changed files with 31 additions and 3 deletions
|
@ -1,8 +1,8 @@
|
||||||
import { debounce, forIn, remove, uniq } from "lodash";
|
import { debounce, forIn, remove, uniq } from "lodash";
|
||||||
import { onlineManager } from "react-query";
|
import { onlineManager } from "react-query";
|
||||||
import { io, Socket } from "socket.io-client";
|
import { io, Socket } from "socket.io-client";
|
||||||
import { Environment } from "../../utilities";
|
import { Environment, isDevEnv } from "../../utilities";
|
||||||
import { ENSURE, LOG } from "../../utilities/console";
|
import { ENSURE, GROUP, LOG } from "../../utilities/console";
|
||||||
import { createDefaultReducer } from "./reducer";
|
import { createDefaultReducer } from "./reducer";
|
||||||
|
|
||||||
class SocketIOClient {
|
class SocketIOClient {
|
||||||
|
@ -31,6 +31,23 @@ class SocketIOClient {
|
||||||
this.reducers = [];
|
this.reducers = [];
|
||||||
|
|
||||||
onlineManager.setOnline(false);
|
onlineManager.setOnline(false);
|
||||||
|
|
||||||
|
if (isDevEnv) {
|
||||||
|
window.socketIO = {
|
||||||
|
dump: () => {
|
||||||
|
GROUP("Socket.IO Reducers", (logger) => {
|
||||||
|
this.reducers.forEach((reducer) => {
|
||||||
|
logger(reducer.key);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
emit: (e) => {
|
||||||
|
if (e) {
|
||||||
|
this.onEvent(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
|
|
2
frontend/src/types/window.d.ts
vendored
2
frontend/src/types/window.d.ts
vendored
|
@ -6,7 +6,7 @@ interface SocketIODebugger {
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
Bazarr: BazarrServer;
|
Bazarr: BazarrServer;
|
||||||
_socketio: SocketIODebugger;
|
socketIO: SocketIODebugger;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface WindowEventMap {
|
interface WindowEventMap {
|
||||||
|
|
|
@ -23,4 +23,15 @@ export function ENSURE(condition: boolean, msg: string, ...payload: any[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function GROUP(
|
||||||
|
header: string,
|
||||||
|
content: (logger: typeof console.log) => void
|
||||||
|
) {
|
||||||
|
if (!isProdEnv) {
|
||||||
|
console.group(header);
|
||||||
|
content(console.log);
|
||||||
|
console.groupEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const ASSERT = console.assert;
|
export const ASSERT = console.assert;
|
||||||
|
|
Loading…
Reference in a new issue