MCSI-2 refactor: add path argument to VanillaServerFileDownloadedEvent

This commit is contained in:
SquidSpirit 2025-07-10 16:05:50 +08:00
parent c5656b9b03
commit 3719023cf9
2 changed files with 8 additions and 4 deletions

View File

@ -50,6 +50,6 @@ class _BasicConfigurationTabState extends State<BasicConfigurationTab> {
}
void _downloadServerFile() {
context.read<VanillaBloc>().add(VanillaServerFileDownloadedEvent());
context.read<VanillaBloc>().add(VanillaServerFileDownloadedEvent('.'));
}
}

View File

@ -28,7 +28,7 @@ class VanillaBloc extends Bloc<VanillaEvent, VanillaState> {
emit(state.copyWith(selectedGameVersion: event.gameVersion));
});
on<VanillaServerFileDownloadedEvent>((_, emit) async {
on<VanillaServerFileDownloadedEvent>((event, emit) async {
final gameVersion = state.selectedGameVersion;
if (gameVersion == null) {
return;
@ -37,7 +37,7 @@ class VanillaBloc extends Bloc<VanillaEvent, VanillaState> {
emit(state.copyWith(isLocked: true));
await _downloadServerFileUseCase(
gameVersion.toEntity(),
path.join('.', Constants.serverFileName),
path.join(event.savePath, Constants.serverFileName),
onProgressChanged: (progress) => add(_VanillaDownloadProgressChangedEvent(progress)),
);
emit(state.copyWith(isLocked: false));
@ -65,7 +65,11 @@ class VanillaGameVersionSelectedEvent extends VanillaEvent {
VanillaGameVersionSelectedEvent(this.gameVersion);
}
class VanillaServerFileDownloadedEvent extends VanillaEvent {}
class VanillaServerFileDownloadedEvent extends VanillaEvent {
final String savePath;
VanillaServerFileDownloadedEvent(this.savePath);
}
class _VanillaDownloadProgressChangedEvent extends VanillaEvent {
final double progress;