loadAppSettings function
Loads all application settings in parallel for improved startup performance.
Returns a tuple of (AppSettings, UserSettings, BlogConfigs, TwoCentsConfigs, WebRTCSettings). Throws FormatException if any JSON file is malformed.
Implementation
Future<OmniBootstrapData> loadAppSettings() async {
// Load all JSON files in parallel for better performance
final results = await Future.wait([
rootBundle.loadString(userSettingsFilePath),
rootBundle.loadString(appSettingsFilePath),
rootBundle.loadString(blogSettingsFilePath),
rootBundle.loadString(twoCentsSettingsFilePath),
rootBundle.loadString(webrtcSettingsFilePath),
]);
final userSettingsJson = json.decode(results[0]) as Map<String, dynamic>;
final appSettingsJson = json.decode(results[1]) as Map<String, dynamic>;
final blogSettingsJson = json.decode(results[2]) as List<dynamic>;
final twoCentsSettingsJson = json.decode(results[3]) as List<dynamic>;
final webrtcSettingsJson = json.decode(results[4]) as Map<String, dynamic>;
final userSettings = UserSettings.fromJsonFile(userSettingsJson);
final appSettings = AppSettings.fromJsonFile(appSettingsJson);
final blogConfigs = blogSettingsJson
.map((e) => BlogPageConfig.fromJsonFile(e as Map<String, dynamic>))
.toList();
final twoCentsConfigs = twoCentsSettingsJson
.map((e) => MyTwoCentsConfig.fromJsonFile(e as Map<String, dynamic>))
.toList();
final webrtcSettings = WebRTCSettings.fromJsonFile(webrtcSettingsJson);
return (
appSettings,
userSettings,
blogConfigs,
twoCentsConfigs,
webrtcSettings,
);
}