Browse Source

Fix firmware badge shown for models without API data (#311)

Printers whose model has no firmware data in Bambu Lab's API (e.g. H2C
on public beta firmware) displayed a misleading green "up to date" badge.
The API returns latest_version=null for these models, so there is nothing
to compare against. Hide the badge when latest_version is not available.

- Add latest_version check to badge render condition in PrintersPage
- Add test for badge hidden when API returns no firmware data
maziggy 3 months ago
parent
commit
19289855de

+ 1 - 0
CHANGELOG.md

@@ -42,6 +42,7 @@ All notable changes to Bambuddy will be documented in this file.
 - **H2D Pro Prints Fail at ~75% With Extrusion Motor Overload** ([#245](https://github.com/maziggy/bambuddy/issues/245)) — H2D Pro firmware interprets `use_ams: 1` (integer) as a nozzle index, routing filament to the deputy nozzle instead of the main nozzle. Bambu Studio sends `use_ams: true` (boolean) while using integers for other fields. Fixed by keeping `use_ams` as boolean for all printers including H2D series.
 - **H2D Pro Prints Fail at ~75% With Extrusion Motor Overload** ([#245](https://github.com/maziggy/bambuddy/issues/245)) — H2D Pro firmware interprets `use_ams: 1` (integer) as a nozzle index, routing filament to the deputy nozzle instead of the main nozzle. Bambu Studio sends `use_ams: true` (boolean) while using integers for other fields. Fixed by keeping `use_ams` as boolean for all printers including H2D series.
 - **GitHub Backup Description Misleading** — The "App Settings" backup card said "excludes sensitive data" but the complete database is pushed. Updated description to "complete database."
 - **GitHub Backup Description Misleading** — The "App Settings" backup card said "excludes sensitive data" but the complete database is pushed. Updated description to "complete database."
 - **Support Bundle Shows 0 AMS Units** — The support info always reported `ams_unit_count: 0` because it expected `raw_data["ams"]` to be a nested dict (`{"ams": [...]}`) but the MQTT handler stores it as a flat list. Now handles both formats.
 - **Support Bundle Shows 0 AMS Units** — The support info always reported `ams_unit_count: 0` because it expected `raw_data["ams"]` to be a nested dict (`{"ams": [...]}`) but the MQTT handler stores it as a flat list. Now handles both formats.
+- **Firmware Badge Shown for Models Without API Data** ([#311](https://github.com/maziggy/bambuddy/issues/311)) — Printers whose model has no firmware data in Bambu Lab's API (e.g. H2C on public beta firmware) showed a misleading green "up to date" badge. The badge is now hidden when the API returns no `latest_version`, since there is nothing to compare against.
 
 
 ### Documentation
 ### Documentation
 - **Supported Printers Updated** — Updated README, website, and wiki to list all 12 supported Bambu Lab printer models: X1, X1C, X1E, P1P, P1S, P2S, A1, A1 Mini, H2D, H2D Pro, H2C, H2S. Removed outdated "Testers Needed" messaging and Tested/Needs Testing distinctions — all models are now uniformly listed as supported. Added H2C printer image to website. Added H2D Pro, H2C columns to wiki feature comparison tables and new P2 Series section.
 - **Supported Printers Updated** — Updated README, website, and wiki to list all 12 supported Bambu Lab printer models: X1, X1C, X1E, P1P, P1S, P2S, A1, A1 Mini, H2D, H2D Pro, H2C, H2S. Removed outdated "Testers Needed" messaging and Tested/Needs Testing distinctions — all models are now uniformly listed as supported. Added H2C printer image to website. Added H2D Pro, H2C columns to wiki feature comparison tables and new P2 Series section.

+ 33 - 0
frontend/src/__tests__/pages/PrintersPage.test.tsx

@@ -274,5 +274,38 @@ describe('PrintersPage', () => {
       expect(screen.queryByText('01.09.00.00')).not.toBeInTheDocument();
       expect(screen.queryByText('01.09.00.00')).not.toBeInTheDocument();
       expect(screen.queryByText('01.08.00.00')).not.toBeInTheDocument();
       expect(screen.queryByText('01.08.00.00')).not.toBeInTheDocument();
     });
     });
+
+    it('hides badge when API has no firmware data for the model', async () => {
+      const firmwareNoData = {
+        printer_id: 1,
+        current_version: '01.01.03.00',
+        latest_version: null,
+        update_available: false,
+        download_url: null,
+        release_notes: null,
+      };
+
+      server.use(
+        http.get('/api/v1/firmware/updates/:id', () => {
+          return HttpResponse.json(firmwareNoData);
+        }),
+        http.get('/api/v1/settings/', () => {
+          return HttpResponse.json({
+            check_printer_firmware: true,
+            auto_archive: true,
+            save_thumbnails: true,
+          });
+        })
+      );
+
+      render(<PrintersPage />);
+
+      await waitFor(() => {
+        expect(screen.getByText('X1 Carbon')).toBeInTheDocument();
+      });
+
+      // Badge should not appear when API returns no latest_version
+      expect(screen.queryByText('01.01.03.00')).not.toBeInTheDocument();
+    });
   });
   });
 });
 });

+ 1 - 1
frontend/src/pages/PrintersPage.tsx

@@ -1992,7 +1992,7 @@ function PrinterCard({
                 </button>
                 </button>
               )}
               )}
               {/* Firmware Version Badge */}
               {/* Firmware Version Badge */}
-              {firmwareInfo?.current_version && (
+              {firmwareInfo?.current_version && firmwareInfo?.latest_version && (
                 <button
                 <button
                   onClick={() => setShowFirmwareModal(true)}
                   onClick={() => setShowFirmwareModal(true)}
                   className={`flex items-center gap-1 px-2 py-1 rounded-full text-xs hover:opacity-80 transition-opacity ${
                   className={`flex items-center gap-1 px-2 py-1 rounded-full text-xs hover:opacity-80 transition-opacity ${

File diff suppressed because it is too large
+ 0 - 0
static/assets/index-CbyBA630.js


+ 1 - 1
static/index.html

@@ -23,7 +23,7 @@
 
 
     <!-- Splash screens for iOS -->
     <!-- Splash screens for iOS -->
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
-    <script type="module" crossorigin src="/assets/index-DKpTCC1_.js"></script>
+    <script type="module" crossorigin src="/assets/index-CbyBA630.js"></script>
     <link rel="stylesheet" crossorigin href="/assets/index-Az-fQOvm.css">
     <link rel="stylesheet" crossorigin href="/assets/index-Az-fQOvm.css">
   </head>
   </head>
   <body>
   <body>

Some files were not shown because too many files changed in this diff