Refactor logging in PrinterDatabase and PrinterManager, and streamline config saving in SocketClient

- Update logging in PrinterDatabase to correctly reference the printer state type.
- Remove redundant call to stopWaiting() in PrinterManager for cleaner code execution.
- Ensure config saving in SocketClient occurs unconditionally for improved reliability.
This commit is contained in:
Tom Butcher 2026-07-27 23:15:20 +01:00
parent 3ca730ecee
commit e2600f8242
3 changed files with 6 additions and 5 deletions

View File

@ -147,7 +147,7 @@ export class PrinterDatabase {
});
logger.info(
`Updated printer: ${chalk.bold.white(this.printer.name)}, State: ${chalk.bold.white(formatState(this.printer.state.type))}${state?.progress ? ` (${state.progress})` : ""} (${online ? chalk.green("Online") : chalk.dim.white("Offline")})`,
`Updated printer: ${chalk.bold.white(this.printer.name)}, State: ${chalk.bold.white(formatState(state.type))}${state?.progress ? ` (${state.progress})` : ""} (${online ? chalk.green("Online") : chalk.dim.white("Offline")})`,
);
return updatedPrinter;

View File

@ -63,9 +63,10 @@ export class PrinterManager {
}
}
await stopWaiting();
logger.debug("Printers added:", addedPrintersCount);
logger.debug("Printers removed:", removedPrintersCount);
await stopWaiting();
} catch (error) {
await stopWaiting();
logger.error("Failed to update printers:", error);

View File

@ -221,9 +221,9 @@ export class SocketClient {
this.id = this.host._id;
config.host = { id: this.id, authCode: this.host.authCode };
if (logs) {
await saveConfig(config);
}
await saveConfig(config);
this.sendDeviceInfo();
this.subscribeToObjectEvents();
this.subscribeToObjectUpdates({ objectType: "host", _id: this.id });