mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
Fix/plugin module namespace collision (#229)
* fix(web): handle string boolean values in schedule-picker widget The normalizeSchedule function used strict equality (===) to check the enabled field, which would fail if the config value was a string "true" instead of boolean true. This could cause the checkbox to always appear unchecked even when the setting was enabled. Added coerceToBoolean helper that properly handles: - Boolean true/false (returns as-is) - String "true", "1", "on" (case-insensitive) → true - String "false" or other values → false Applied to both main schedule enabled and per-day enabled fields. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: trim whitespace in coerceToBoolean string handling * fix: normalize mode value to handle per_day and per-day variants * fix(plugins): resolve module namespace collisions between plugins When multiple plugins have modules with the same name (e.g., data_fetcher.py), Python's sys.modules cache would return the wrong module. This caused plugins like ledmatrix-stocks to fail loading because it imported data_fetcher from ledmatrix-leaderboard instead of its own. Added _clear_conflicting_modules() to remove cached plugin modules from sys.modules before loading each plugin, ensuring correct module resolution. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Chuck <chuck@example.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -114,6 +114,18 @@
|
||||
return Boolean(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize mode value to handle both 'per_day' and 'per-day' variants.
|
||||
*/
|
||||
function normalizeMode(mode) {
|
||||
if (!mode || typeof mode !== 'string') {
|
||||
return 'global';
|
||||
}
|
||||
// Normalize: replace hyphens with underscores and check for per_day
|
||||
const normalized = mode.trim().toLowerCase().replace(/-/g, '_');
|
||||
return normalized === 'per_day' ? 'per_day' : 'global';
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge user value with defaults
|
||||
*/
|
||||
@@ -125,7 +137,7 @@
|
||||
|
||||
const schedule = {
|
||||
enabled: coerceToBoolean(value.enabled),
|
||||
mode: value.mode === 'per_day' ? 'per_day' : 'global',
|
||||
mode: normalizeMode(value.mode),
|
||||
start_time: value.start_time || defaults.start_time,
|
||||
end_time: value.end_time || defaults.end_time,
|
||||
days: {}
|
||||
|
||||
Reference in New Issue
Block a user