Implement incremental loading via streaming
This commit is contained in:
@@ -177,7 +177,7 @@ class ModList {
|
||||
|
||||
ModList({required this.path});
|
||||
|
||||
void load() {
|
||||
Stream<Mod> load() async* {
|
||||
final directory = Directory(path);
|
||||
print('Loading configuration from: $path');
|
||||
|
||||
@@ -187,8 +187,12 @@ class ModList {
|
||||
entities.whereType<Directory>().map((dir) => dir.path).toList();
|
||||
|
||||
print('Found ${modDirectories.length} mod directories:');
|
||||
|
||||
for (final modDir in modDirectories) {
|
||||
try {
|
||||
// Add a small delay to prevent UI freezing and give time for rendering
|
||||
await Future.delayed(const Duration(milliseconds: 5));
|
||||
|
||||
final mod = Mod.fromDirectory(modDir);
|
||||
mods[mod.id] = mod;
|
||||
print(
|
||||
@@ -198,6 +202,8 @@ class ModList {
|
||||
'Soft Dependencies: ${mod.softDependencies.join(', ')}, '
|
||||
'Incompatibilities: ${mod.incompatabilities.join(', ')}',
|
||||
);
|
||||
|
||||
yield mod;
|
||||
print('Current total mods loaded: ${mods.length}');
|
||||
} catch (e) {
|
||||
print('Error loading mod from directory: $modDir');
|
||||
|
Reference in New Issue
Block a user