Skip to content

Commit

Permalink
fix(server): unable to detach spools from printer
Browse files Browse the repository at this point in the history
Server wasn't running the detach command when no printer id was supplied

Closes: #1232
  • Loading branch information
NotExpectedYet committed Oct 1, 2022
1 parent 1ed2977 commit 20c3489
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function selectFilament(spools, id) {
let printerIds = [];
for (const spool of spools) {
const meta = spool.split("-");

printerIds.push({
printer: meta[0],
tool: meta[1],
Expand Down
1 change: 0 additions & 1 deletion server/routes/filament-manager.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ router.get('/get/dropDownList', ensureAuthenticated, async (_req, res) => {
router.post('/assign', ensureAuthenticated, async (req, res) => {
logger.info('Request to change selected spool:', req.body.printers);
const multiSelectEnabled = SettingsClean.isMultipleSelectEnabled();

await getPrinterStoreCache().assignSpoolToPrinters(
req.body.printers,
req.bodyString('spoolId'),
Expand Down
2 changes: 1 addition & 1 deletion server/services/printers/create-octoprint.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ class OctoPrintPrinter {

updatePrinterData(data) {
logger.silly('Updating printer database: ', data);
this.#db.update(data);
this?.#db?.update(data);
}

resetApiTimeout() {
Expand Down
2 changes: 2 additions & 0 deletions server/store/printers.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1343,13 +1343,15 @@ class PrinterStore {
for (let id of printerIDs) {
// No tool is de-attach request
if (!id?.tool) {
this.deattachSpoolFromAllPrinters(spoolID);
break;
}
const tool = id.tool;
const printerID = id.printer;
const printerIndex = findIndex(farmPrinters, function (o) {
return o._id === printerID;
});

if (spoolID !== '0') {
const spool = await Filament.findById(spoolID);
farmPrinters[printerIndex].selectedFilament[tool] = JSON.parse(JSON.stringify(spool));
Expand Down

0 comments on commit 20c3489

Please sign in to comment.