Skip to content

Commit

Permalink
Fix: only show loading indicator when loading repo creation page
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Pabon committed Aug 13, 2024
1 parent fc57b61 commit 2796c66
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions lib/app/cubits/repo_creation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,22 @@ class RepoCreationCubit extends Cubit<RepoCreationState> with AppLogger {
return;
}

await _loading(() async {
final accessMode = await token.mode;
final suggestedName = await token.suggestedName;
final useCacheServers =
await reposCubit.cacheServers.isEnabledForShareToken(token);

emit(state.copyWith(
accessMode: accessMode,
suggestedName: suggestedName,
token: token,
useCacheServers: useCacheServers,
));
});
await _loading(
() async {
final accessMode = await token.mode;
final suggestedName = await token.suggestedName;
final useCacheServers =
await reposCubit.cacheServers.isEnabledForShareToken(token);

emit(state.copyWith(
accessMode: accessMode,
suggestedName: suggestedName,
token: token,
useCacheServers: useCacheServers,
));
},
showLoading: true,
);
}

void acceptSuggestedName() {
Expand Down Expand Up @@ -255,10 +258,15 @@ class RepoCreationCubit extends Cubit<RepoCreationState> with AppLogger {
}
}

Future<R> _loading<R>(Future<R> Function() f) async {
Future<R> _loading<R>(
Future<R> Function() f, {
bool showLoading = false,
}) async {
try {
emit(state.copyWith(loading: true));
return await Dialogs.executeFutureWithLoadingDialog(null, f.call());
return showLoading
? await Dialogs.executeFutureWithLoadingDialog(null, f.call())
: await f();
} finally {
emit(state.copyWith(loading: false));
}
Expand Down

0 comments on commit 2796c66

Please sign in to comment.