-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PE-7214: feat(primary name) #1927
Merged
thiagocarvalhodev
merged 17 commits into
dev
from
PE-7214-show-ar-ns-primary-name-on-ar-drive
Dec 3, 2024
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4c3b336
feat(primary name)
thiagocarvalhodev a243a3b
Update app_router_delegate.dart
thiagocarvalhodev 96c3ebd
Update profile_name_bloc.dart
thiagocarvalhodev 36a7ed1
feat(primary name)
thiagocarvalhodev 20ea9d5
feat(primary name): implement unit tests
thiagocarvalhodev fcb6c5d
Update ario_sdk_web.dart
thiagocarvalhodev c6c2d0b
Update profile_name_state.dart
thiagocarvalhodev 39cddca
Update index.js
thiagocarvalhodev f335f20
feat(profile name)
thiagocarvalhodev a191a8e
Update response_object.dart
thiagocarvalhodev 5c12fee
Update profile_card.dart
thiagocarvalhodev ac24962
fix truncation
thiagocarvalhodev 1d670a2
Update profile_name_bloc_test.dart
thiagocarvalhodev ff6a5ee
Delete profile_name_view.dart
thiagocarvalhodev 15fcf0e
Update profile_card.dart
thiagocarvalhodev 8cba7e5
Update profile_card.dart
thiagocarvalhodev 05cd68d
Update profile_card.dart
thiagocarvalhodev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,62 @@ | ||
import 'package:ardrive/arns/domain/arns_repository.dart'; | ||
import 'package:ardrive/authentication/ardrive_auth.dart'; | ||
import 'package:ardrive/utils/logger.dart'; | ||
import 'package:ario_sdk/ario_sdk.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
part 'profile_name_event.dart'; | ||
part 'profile_name_state.dart'; | ||
|
||
class ProfileNameBloc extends Bloc<ProfileNameEvent, ProfileNameState> { | ||
final ARNSRepository _arnsRepository; | ||
final ArDriveAuth _auth; | ||
|
||
ProfileNameBloc(this._arnsRepository, this._auth) | ||
: super(ProfileNameInitial(_auth.currentUser.walletAddress)) { | ||
on<LoadProfileName>((event, emit) async { | ||
await _loadProfileName( | ||
walletAddress: _auth.currentUser.walletAddress, | ||
refresh: false, | ||
emit: emit, | ||
); | ||
}); | ||
on<RefreshProfileName>((event, emit) async { | ||
await _loadProfileName( | ||
walletAddress: _auth.currentUser.walletAddress, | ||
refresh: true, | ||
emit: emit, | ||
); | ||
}); | ||
} | ||
|
||
Future<void> _loadProfileName({ | ||
required String walletAddress, | ||
required bool refresh, | ||
required Emitter<ProfileNameState> emit, | ||
}) async { | ||
try { | ||
/// if we are not refreshing, we emit a loading state | ||
if (!refresh) { | ||
emit(ProfileNameLoading(walletAddress)); | ||
} | ||
|
||
final primaryName = | ||
await _arnsRepository.getPrimaryName(walletAddress, update: refresh); | ||
|
||
emit(ProfileNameLoaded(primaryName, walletAddress)); | ||
} catch (e) { | ||
if (e is PrimaryNameNotFoundException) { | ||
logger.d('Primary name not found for address: $walletAddress'); | ||
} else { | ||
logger.e('Error getting primary name.', e); | ||
} | ||
|
||
emit( | ||
ProfileNameLoadedWithWalletAddress( | ||
walletAddress, | ||
), | ||
); | ||
} | ||
} | ||
} |
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 'profile_name_bloc.dart'; | ||
|
||
sealed class ProfileNameEvent extends Equatable { | ||
const ProfileNameEvent(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
final class RefreshProfileName extends ProfileNameEvent {} | ||
|
||
final class LoadProfileName extends ProfileNameEvent {} |
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,44 @@ | ||
part of 'profile_name_bloc.dart'; | ||
|
||
sealed class ProfileNameState extends Equatable { | ||
const ProfileNameState(); | ||
|
||
abstract final String walletAddress; | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
final class ProfileNameInitial extends ProfileNameState { | ||
const ProfileNameInitial(this.walletAddress); | ||
|
||
@override | ||
final String walletAddress; | ||
} | ||
|
||
final class ProfileNameLoading extends ProfileNameState { | ||
@override | ||
final String walletAddress; | ||
|
||
const ProfileNameLoading(this.walletAddress); | ||
} | ||
|
||
final class ProfileNameLoaded extends ProfileNameState { | ||
final String primaryName; | ||
|
||
const ProfileNameLoaded(this.primaryName, this.walletAddress); | ||
|
||
@override | ||
final String walletAddress; | ||
|
||
@override | ||
List<Object> get props => [primaryName, walletAddress]; | ||
} | ||
|
||
// if fails to load primary name, show current wallet address | ||
final class ProfileNameLoadedWithWalletAddress extends ProfileNameState { | ||
@override | ||
final String walletAddress; | ||
|
||
const ProfileNameLoadedWithWalletAddress(this.walletAddress); | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
library ario_sdk; | ||
|
||
export 'src/ario_sdk.dart'; | ||
export 'src/exceptions.dart'; | ||
export 'src/factory.dart'; | ||
export 'src/models/models.dart'; | ||
export 'src/utils/utils.dart'; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this won't truncate primary names to max 20 and add ... ? Or is it handled elsewhere?