Skip to content

Time Controlled Presets/macros drop-downs do not populate on some devices #5840

Description

@UsableLoki8221

What happened?

The drop-down to select preset shows empty on devices like phones vs workstation browsers. In settings_time.htm the line json = JSON.parse(localStorage.getItem("wledP")); is null when running off my phone's browser.

To Reproduce Bug

Try it off other devices

Expected Behavior

Presets should be getting loaded for drop-downs across range of devices

Install Method

Self-Compiled

What version of WLED?

WLED 17.0.0-devV5 (2607201)

Which microcontroller/board are you seeing the problem on?

ESP32-C3

Relevant log/trace output

Anything else?

I believe I found a fix- on settings_time.htm I updated populatePresets(fromls) to...

function populatePresets(fromls) { let json = null; 
	if (fromls) { 
		try { 
			json = JSON.parse(localStorage.getItem("wledP")); 
		} catch (e) { 
			console.log("Unable to parse cached presets:", e); 
		} 
	}
	if (json) { 
		onPresetsLoaded(json); 
		return; 
	} 
	fetch(getURL("/presets.json")) 
		.then(response => { 
			if (!response.ok) {
				 throw new Error("HTTP " + response.status);
			} return response.json(); 
		}) 
		.then(json => { 
			try { 
				localStorage.setItem("wledP", JSON.stringify(json)); 
			} catch (e) {
				console.log("Unable to cache presets:", e); 
			} 
			onPresetsLoaded(json); 
		}) 
		.catch(error => { 
			console.log("Unable to load presets:", error); 
			showToast("Unable to load presets", true);
		}); }

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcannot reproduceDevelopers are not able reproduce. Might be fixed already, or report is missing important details

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions