Skip to content

Commit

Permalink
fix(logo)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagocarvalhodev committed Dec 18, 2024
1 parent 0c76ad5 commit 04a1384
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class _EnterYourPasswordWidgetState extends State<EnterYourPasswordWidget> {

context
.read<ProfileNameBloc>()
.add(LoadProfileNameAnonymous(walletAddress ?? ''));
.add(LoadProfileNameBeforeLogin(walletAddress ?? ''));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class _SecureYourWalletWidgetState extends State<SecureYourWalletWidget> {

context
.read<ProfileNameBloc>()
.add(LoadProfileNameAnonymous(walletAddress));
.add(LoadProfileNameBeforeLogin(walletAddress));
});
}

Expand Down
4 changes: 2 additions & 2 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class UploadCubit extends Cubit<UploadState> {
);

emit(UploadingManifests(
manifestFiles: manifestModels,
manifestFiles: manifestModels,
completedCount: completedCount,
));

Expand Down Expand Up @@ -266,7 +266,7 @@ class UploadCubit extends Cubit<UploadState> {
name: manifestModels[i].undername!.name,
domain: manifestModels[i].antRecord!.domain,
record: ARNSRecord(
transactionId: manifestFile.dataTxId,
transactionId: manifestFile.dataTxId,
ttlSeconds: 3600,
),
);
Expand Down
35 changes: 20 additions & 15 deletions lib/user/name/presentation/bloc/profile_name_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ class ProfileNameBloc extends Bloc<ProfileNameEvent, ProfileNameState> {
on<LoadProfileName>((event, emit) async {
await _loadProfileName(
walletAddress: _auth.currentUser.walletAddress,
refresh: false,
refreshName: false,
refreshLogo: false,
emit: emit,
);
});
on<RefreshProfileName>((event, emit) async {
await _loadProfileName(
walletAddress: _auth.currentUser.walletAddress,
refresh: true,
refreshName: true,
refreshLogo: true,
emit: emit,
);
});
on<LoadProfileNameAnonymous>((event, emit) async {
on<LoadProfileNameBeforeLogin>((event, emit) async {
emit(ProfileNameLoading(event.walletAddress));

logger
.d('Loading profile name for anonymous user ${event.walletAddress}');

await _loadProfileName(
walletAddress: event.walletAddress,
refresh: true,
refreshName: true,
refreshLogo: false,
emit: emit,
isUserLoggedIn: false,
);
Expand All @@ -53,32 +53,37 @@ class ProfileNameBloc extends Bloc<ProfileNameEvent, ProfileNameState> {

Future<void> _loadProfileName({
required String walletAddress,
required bool refresh,
required bool refreshName,
required bool refreshLogo,
required Emitter<ProfileNameState> emit,
bool isUserLoggedIn = true,
}) async {
try {
String? profileLogoTxId;

/// if we are not refreshing, we emit a loading state
if (!refresh) {
if (!refreshName) {
emit(ProfileNameLoading(walletAddress));
}

if (refresh && !isUserLoggedIn) {
if (!refreshLogo) {
logger.d('Getting profile logo tx id from cache');

profileLogoTxId =
await _profileLogoRepository.getProfileLogoTxId(walletAddress);

logger.d('Profile logo tx id: $profileLogoTxId');
}

var primaryNameDetails = await _arnsRepository.getPrimaryName(
walletAddress,
update: refresh,
getLogo: profileLogoTxId == null,
update: refreshName,
getLogo: refreshLogo,
);

primaryNameDetails = primaryNameDetails.copyWith(
logo: profileLogoTxId == null ? primaryNameDetails.logo : null,
);
if (refreshLogo && profileLogoTxId != null) {
primaryNameDetails = primaryNameDetails.copyWith(logo: profileLogoTxId);
}

if (isUserLoggedIn && _auth.currentUser.walletAddress != walletAddress) {
// A user can load profile name and log out while fetching this request. Then log in again. We should not emit a profile name loaded state in this case.
Expand Down
4 changes: 2 additions & 2 deletions lib/user/name/presentation/bloc/profile_name_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ final class RefreshProfileName extends ProfileNameEvent {}

final class LoadProfileName extends ProfileNameEvent {}

final class LoadProfileNameAnonymous extends ProfileNameEvent {
final class LoadProfileNameBeforeLogin extends ProfileNameEvent {
final String walletAddress;

const LoadProfileNameAnonymous(this.walletAddress);
const LoadProfileNameBeforeLogin(this.walletAddress);
}

final class CleanProfileName extends ProfileNameEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Future<PrimaryNameDetails> _getPrimaryNameImpl(

return PrimaryNameDetails(
primaryName: json['primaryName']['name'],
logo: json['antInfo']['Logo'],
logo: json['antInfo']?['Logo'],
recordId: json['arnsRecord']?['processId'],
);
}

0 comments on commit 04a1384

Please sign in to comment.