Migrate Zoom Shortcuts to WME SDK and convert old settings
- Switched shortcut registration to new SDK
- Legacy user settings are migrated to the SDK format
Auto-resolve duplicate shortcut key conflicts
Catch SDK registration errors for duplicate key combinations, automatically
Reset conflicting shortcuts to null, and retry registration. Prevents script Failure and ensures all zoom shortcuts are registered successfully.
feat: Add defensive coding for WME SDK shortcut format inconsistency
PROBLEM:
The WME SDK returns shortcut keys in inconsistent formats depending on timing:
- Initial page load: combo format ("0", "A+X", "CS+K")
- After user changes shortcuts: raw format ("0,48", "4,65", "3,75")
- After page reload: back to combo format again
This caused our localStorage to contain mixed/invalid data like:
{
"zoom10": {"raw": "0", "combo": "0"}, // Should be "0,48"
"zoom11": {"raw": "1", "combo": "1"}, // Should be "0,49"
"zoom20": {"raw": "4,48", "combo": "A+0"} // This one was correct
}
SOLUTION:
Added comprehensive defensive coding to handle SDK inconsistency:
Enhanced comboToRawKeycodes():
- Now handles single chars ("0" → "0,48")
- Preserves already-raw format ("0,48" → "0,48")
- Converts combo format ("A+0" → "4,48")
Improved shortcutKeycodesToCombo():
- Handles both raw and combo inputs reliably
- Always returns consistent human-readable format
Updated loadSettingsFromStorage():
- Validates and normalizes existing stored data
- Fixes inconsistent raw/combo pairs from previous runs
- Regenerates missing raw or combo values
- Prevents future corruption
Enhanced saveSettings():
- Added logging to track what format SDK returns
- Normalizes SDK output before storage
- Ensures consistent storage format regardless of SDK behavior
Strengthened legacy migration:
- Handles more legacy format variations
- Better type checking and error handling
- More detailed logging for troubleshooting
IMPACT:
- Eliminates storage corruption from SDK format inconsistency
- Provides reliable round-trip storage/retrieval of shortcuts
- Self-heals existing corrupted data on next load
- Maintains backward compatibility with legacy settings
- Extensive logging for debugging future issues
TESTING:
After these changes, localStorage consistently shows proper format:
{
"zoom10": {"raw": "0,48", "combo": "0"},
"zoom11": {"raw": "0,49", "combo": "1"}
}
This defensive approach ensures the script works reliably regardless of
when/how the SDK decides to change its return format behavior.
Merge pull request #1 from JS55CT/master
Master