mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 08:25:54 +02:00
[PR #581] [MERGED] Refactor frontend utility functions to reduce duplication #1079
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy-maziggy-1#1079
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/maziggy/bambuddy/pull/581
Author: @aneopsy
Created: 3/3/2026
Status: ✅ Merged
Merged: 3/4/2026
Merged by: @maziggy
Base:
0.2.2b1← Head:refactor-utils📝 Commits (3)
15521deRefactor date and currency utility functionsabe40f1Consolidate duplicate utility functions into shared modulesba2abe1Merge branch '0.2.2b1' into refactor-utils📊 Changes
15 files changed (+8840 additions, -303 deletions)
View changed files
📝
frontend/src/components/FilamentHoverCard.tsx(+1 -11)📝
frontend/src/components/FileManagerModal.tsx(+0 -1)📝
frontend/src/components/GitHubBackupSettings.tsx(+6 -6)📝
frontend/src/components/SpoolUsageHistory.tsx(+4 -5)📝
frontend/src/components/TimelapseEditorModal.tsx(+5 -10)📝
frontend/src/components/TimelapseViewer.tsx(+3 -8)📝
frontend/src/contexts/ToastContext.tsx(+2 -9)📝
frontend/src/pages/PrintersPage.tsx(+5 -86)📝
frontend/src/pages/ProjectDetailPage.tsx(+3 -17)📝
frontend/src/pages/spoolbuddy/SpoolBuddySettingsPage.tsx(+0 -1)📝
frontend/src/utils/colors.ts(+30 -0)📝
frontend/src/utils/currency.ts(+4 -28)📝
frontend/src/utils/date.ts(+78 -120)📝
frontend/src/utils/file.ts(+1 -1)➕
static/assets/index-BAl7JF0v.js(+8698 -0)📄 Description
Description
Consolidate duplicate helper functions scattered across frontend components into shared utility modules, reducing code duplication while preserving exact UI behavior. No visual or functional changes, every local function was verified against its shared replacement through multiple behavioral reviews.
Related Issue
Type of Change
Changes Made
isLightColor,parseFilamentColor,hexToColorName(with brown detection) intoutils/colors.tsformatMediaTime,formatDurationFromHourstoutils/date.ts; refactordetectSystemDateFormat,parseDateInput,parseTimeInput,formatETASUPPORTED_CURRENCIESfromCURRENCY_SYMBOLSmap inutils/currency.tsformatFileSizeguard for NaN/negative inputs inutils/file.tsformatTime(TimelapseViewer, TimelapseEditorModal) andformatBytes(ToastContext)formatFilament,formatStorageSize,formatUptime,formatDateTime,formatTimeAgo)Screenshots
N/A — pure refactoring with no visual changes.
Testing
I have tested this on my local machine
I have tested with my printer model:
npm run buildpasses (tsc -b + Vite)All 1029 frontend tests pass
All 1783 backend tests pass
Multiple behavioral code reviews confirmed zero UI changes
Checklist
Additional Notes
Net result: -161 lines across 16 files. Only truly identical functions were consolidated; any function with even slightly different formatting (decimal precision, time interpretation, locale handling) was kept local to guarantee no behavior change.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.