@@ -18,17 +18,22 @@ void PluginScheduler::addItem(int pluginId, unsigned long durationSeconds)
1818
1919void PluginScheduler::clearSchedule (bool emptyStorage)
2020{
21- schedule.clear ();
2221 currentIndex = 0 ;
2322 isActive = false ;
2423#ifdef ENABLE_STORAGE
2524 if (emptyStorage)
2625 {
27- storage.begin (" led-wall" , false );
26+ schedule.clear ();
27+ storage.begin (" led-wall" );
2828 storage.putString (" schedule" , " " );
2929 storage.putInt (" scheduleactive" , 0 );
3030 storage.end ();
3131 }
32+ #else
33+ if (emptyStorage)
34+ {
35+ schedule.clear ();
36+ }
3237#endif
3338}
3439
@@ -78,7 +83,7 @@ void PluginScheduler::switchToCurrentPlugin()
7883 {
7984 pluginManager.setActivePluginById (schedule[currentIndex].pluginId );
8085#ifdef ENABLE_SERVER
81- sendMinimalInfo ();
86+ sendInfo ();
8287#endif
8388 }
8489}
@@ -118,26 +123,22 @@ bool PluginScheduler::setScheduleByJSONString(String scheduleJson)
118123 }
119124
120125#ifdef ENABLE_STORAGE
121- storage.begin (" led-wall" , false );
126+ storage.begin (" led-wall" );
122127 storage.putString (" schedule" , scheduleJson);
123128 storage.end ();
124129#endif
125130
126- Scheduler. clearSchedule ();
131+ clearSchedule ();
127132
128- JsonArray schedule = doc.as <JsonArray>();
129- for (JsonObject item : schedule)
133+ for (const auto &item : doc.as <JsonArray>())
130134 {
131- if (! item.containsKey (" pluginId" ) || ! item.containsKey (" duration" ))
135+ if (item.containsKey (" pluginId" ) && item.containsKey (" duration" ))
132136 {
133- return false ;
137+ int pluginId = item[" pluginId" ].as <int >();
138+ unsigned long duration = item[" duration" ].as <unsigned long >();
139+ addItem (pluginId, duration);
134140 }
135-
136- int pluginId = item[" pluginId" ].as <int >();
137- unsigned long duration = item[" duration" ].as <unsigned long >();
138- Scheduler.addItem (pluginId, duration);
139141 }
140-
141142 return true ;
142143}
143144
0 commit comments