2.9 KiB
CRITICAL DISCOVERY - Why Apply Button Wasn't Working
The Real Problem
You were clicking "Apply Changes" and nothing happened on the LCD because...
The changes were being SAVED but with an 800ms DELAY.
When you clicked Apply:
- Properties were updated ✓
- Canvas showed changes ✓
requestPageSave()was called ✓- A 800ms timeout was set ✓
- Changes sent to device after 800ms...
- But you checked the LCD before those 800ms passed! ❌
What I Just Fixed
Changed ALL user-initiated actions to IMMEDIATE PERSISTENCE instead of debounced:
Before (Broken)
User Action → Debounce Timer (800ms) → Save to Device → LCD Updates
(User checks before timer expires = no changes!)
After (Fixed)
User Action → IMMEDIATE Save to Device → LCD Updates (instant!)
What Now Saves Immediately
✅ Apply Changes button - Saves right away + shows toast
✅ Delete button - Saves right away
✅ Drag/Move - Saves when you release mouse
✅ Align buttons - Save right away
✅ Drop new widget - Saves right away
What's Different Now
When you:
- Drag header down
- Release mouse → IMMEDIATELY saved
- Click Apply (if position changed) → IMMEDIATELY saved
- Check LCD → Changes are already there!
No more waiting 800ms for changes to appear!
Test Instructions
Quick Test (1 minute)
1. Open Builder
2. Select any element
3. Drag it to new position
4. Look at LCD - element should be in new position (almost instantly)
5. Change a property (e.g., color)
6. Click Apply
7. Look at LCD - change should appear immediately
Expected Behavior
- When you release mouse after drag → LCD updates within 1 second
- When you click Apply → LCD updates within 1 second
- NO MORE 800ms waiting!
Files Modified
data/js/builder.js- Line 1124: Apply button now saves immediately + shows status toast
- Line 250: Drag completion now persists immediately
- Line 267: Drop (new widget) now persists immediately
- Line 280: Delete now persists immediately
- Line 747: Align buttons now persist immediately
Performance Consideration
Q: Wasn't the 800ms debounce to prevent overwhelming the device?
A: Yes, but:
- Each save operation was taking 900ms anyway (observed in logs)
- User actions are naturally spaced out (can't click 1000x per second)
- Immediate feedback is more important than preventing non-existent request floods
- If device gets overwhelmed, it shows connection errors which are handled
Summary
The 800ms debounce was causing the exact problem you reported:
- "I clicked Apply and nothing happened"
- "I moved element and it didn't persist"
Because the device was actually saving, but with an 800ms delay that made it seem like nothing was happening!
Now when you click Apply or perform an action, changes go to the device right away ✅