-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into PE-6654-new-upload-UI
- Loading branch information
Showing
26 changed files
with
482 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Fixes an issue attaching drives due to timeout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- Integrated ar.io SDK for gateway switching and IO token balance display. | ||
- Enabled ArNS names and under_names for public files using the ar.io SDK. | ||
- Added option to assign an ArNS name to single file uploads. | ||
- Added option to assign an ArNS name during manifest creation. | ||
- Improved details panel styling, especially for Light Theme. | ||
- Updated tooltips for better clarity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Asynchronous background fetching of AR and tIO balances with improved loading and error handling. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:ardrive/authentication/ardrive_auth.dart'; | ||
import 'package:ardrive/user/user.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
part 'user_balance_event.dart'; | ||
part 'user_balance_state.dart'; | ||
|
||
class UserBalanceBloc extends Bloc<UserBalanceEvent, UserBalanceState> { | ||
final ArDriveAuth _auth; | ||
StreamSubscription<User?>? _userSubscription; | ||
|
||
UserBalanceBloc({required ArDriveAuth auth}) | ||
: _auth = auth, | ||
super(UserBalanceInitial()) { | ||
on<GetUserBalance>(_onGetUserBalance); | ||
on<RefreshUserBalance>(_onRefreshUserBalance); | ||
} | ||
|
||
Future<void> _onGetUserBalance( | ||
GetUserBalance event, Emitter<UserBalanceState> emit) async { | ||
await _cancelSubscription(); | ||
|
||
final user = _auth.currentUser; | ||
_emitUserBalanceState(user, emit); | ||
|
||
_userSubscription = _auth.onAuthStateChanged().listen((user) { | ||
if (isClosed) return; | ||
_emitUserBalanceState(user, emit); | ||
if (user?.ioTokens != null) { | ||
_cancelSubscription(); | ||
} | ||
}); | ||
|
||
await _userSubscription?.asFuture(); | ||
} | ||
|
||
Future<void> _onRefreshUserBalance( | ||
RefreshUserBalance event, Emitter<UserBalanceState> emit) async { | ||
if (isClosed) return; | ||
|
||
await _cancelSubscription(); | ||
|
||
emit(UserBalanceLoadingIOTokens( | ||
arBalance: _auth.currentUser.walletBalance, | ||
errorFetchingIOTokens: false, | ||
)); | ||
|
||
_auth.refreshBalance(); | ||
|
||
_userSubscription = _auth.onAuthStateChanged().listen((user) { | ||
if (isClosed) return; | ||
_emitUserBalanceState(user, emit); | ||
if (user?.ioTokens != null) { | ||
_cancelSubscription(); | ||
} | ||
}); | ||
|
||
await _userSubscription?.asFuture(); | ||
} | ||
|
||
Future<void> _cancelSubscription() async { | ||
if (_userSubscription != null) { | ||
await _userSubscription!.cancel(); | ||
_userSubscription = null; | ||
} | ||
} | ||
|
||
void _emitUserBalanceState(User? user, Emitter<UserBalanceState> emit) { | ||
if (user == null) return; | ||
|
||
if (user.ioTokens == null && !user.errorFetchingIOTokens) { | ||
emit(UserBalanceLoadingIOTokens( | ||
arBalance: user.walletBalance, | ||
errorFetchingIOTokens: user.errorFetchingIOTokens, | ||
)); | ||
} else { | ||
emit(UserBalanceLoaded( | ||
arBalance: user.walletBalance, | ||
ioTokens: user.ioTokens, | ||
errorFetchingIOTokens: user.errorFetchingIOTokens, | ||
)); | ||
} | ||
} | ||
|
||
@override | ||
Future<void> close() async { | ||
await _cancelSubscription(); | ||
return super.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
part of 'user_balance_bloc.dart'; | ||
|
||
sealed class UserBalanceEvent extends Equatable { | ||
const UserBalanceEvent(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
final class GetUserBalance extends UserBalanceEvent {} | ||
|
||
final class RefreshUserBalance extends UserBalanceEvent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
part of 'user_balance_bloc.dart'; | ||
|
||
sealed class UserBalanceState extends Equatable { | ||
const UserBalanceState(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
final class UserBalanceInitial extends UserBalanceState {} | ||
|
||
final class UserBalanceLoaded extends UserBalanceState { | ||
final BigInt arBalance; | ||
final String? ioTokens; | ||
final bool errorFetchingIOTokens; | ||
|
||
const UserBalanceLoaded({ | ||
required this.arBalance, | ||
required this.ioTokens, | ||
required this.errorFetchingIOTokens, | ||
}); | ||
} | ||
|
||
final class UserBalanceLoadingIOTokens extends UserBalanceLoaded { | ||
const UserBalanceLoadingIOTokens({ | ||
required super.arBalance, | ||
super.ioTokens, | ||
super.errorFetchingIOTokens = false, | ||
}); | ||
} |
Oops, something went wrong.