addSession function
Adds a new session to the existing TTL content. If currentContent is null or empty, initializes with prefixes. Returns the updated TTL content string.
Implementation
String addSession(String? currentContent, Map<String, dynamic> newSession) {
List<Map<String, String>> sessions = parseSessions(currentContent);
// Convert map values to String
final Map<String, String> sessionToAdd = {
'start': newSession['start'].toString(),
'end': newSession['end'].toString(),
'type': (newSession['type'] ?? 'bell').toString(),
'silenceDuration': (newSession['silenceDuration'] ?? 1200).toString(),
'title': (newSession['title'] ?? '').toString(),
'description': (newSession['description'] ?? '').toString(),
};
sessions.add(sessionToAdd);
return serializeSessions(sessions);
}