cp延后
This commit is contained in:
parent
4d86236227
commit
9a11487059
@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:yumi/app_localizations.dart';
|
||||
@ -170,19 +172,20 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
||||
final loadedProfile = await SCAccountRepository().loadUserInfo(
|
||||
normalizedUserId,
|
||||
);
|
||||
var mergedProfile = await _withCurrentVipLevel(
|
||||
loadedProfile,
|
||||
normalizedUserId,
|
||||
);
|
||||
mergedProfile = await _withCpCabinProfiles(
|
||||
mergedProfile,
|
||||
normalizedUserId,
|
||||
);
|
||||
if (requestSerial != _userInfoRequestSerial) {
|
||||
return;
|
||||
}
|
||||
userProfile = mergedProfile;
|
||||
userProfile = loadedProfile;
|
||||
userProfileLoadError = null;
|
||||
isUserProfileLoading = false;
|
||||
notifyListeners();
|
||||
unawaited(
|
||||
_hydrateUserInfoById(
|
||||
profile: loadedProfile,
|
||||
userId: normalizedUserId,
|
||||
requestSerial: requestSerial,
|
||||
),
|
||||
);
|
||||
} catch (error, stackTrace) {
|
||||
if (requestSerial != _userInfoRequestSerial) {
|
||||
return;
|
||||
@ -196,7 +199,7 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
} finally {
|
||||
if (requestSerial == _userInfoRequestSerial) {
|
||||
if (requestSerial == _userInfoRequestSerial && isUserProfileLoading) {
|
||||
isUserProfileLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
@ -234,12 +237,20 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
||||
normalizedRoomId,
|
||||
normalizedUserId,
|
||||
);
|
||||
card = await _withCurrentVipLevelForCard(card, normalizedUserId);
|
||||
if (requestSerial != _userCardRequestSerial) {
|
||||
return;
|
||||
}
|
||||
userCardInfo = card;
|
||||
userCardLoadError = null;
|
||||
isUserCardLoading = false;
|
||||
notifyListeners();
|
||||
unawaited(
|
||||
_hydrateRoomUserCard(
|
||||
card: card,
|
||||
userId: normalizedUserId,
|
||||
requestSerial: requestSerial,
|
||||
),
|
||||
);
|
||||
} catch (error, stackTrace) {
|
||||
if (requestSerial != _userCardRequestSerial) {
|
||||
return;
|
||||
@ -253,13 +264,60 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
} finally {
|
||||
if (requestSerial == _userCardRequestSerial) {
|
||||
if (requestSerial == _userCardRequestSerial && isUserCardLoading) {
|
||||
isUserCardLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _hydrateUserInfoById({
|
||||
required SocialChatUserProfile profile,
|
||||
required String userId,
|
||||
required int requestSerial,
|
||||
}) async {
|
||||
try {
|
||||
var mergedProfile = await _withCurrentVipLevel(profile, userId);
|
||||
mergedProfile = await _withCpCabinProfiles(mergedProfile, userId);
|
||||
if (requestSerial != _userInfoRequestSerial) {
|
||||
return;
|
||||
}
|
||||
userProfile = mergedProfile;
|
||||
userProfileLoadError = null;
|
||||
notifyListeners();
|
||||
} catch (error, stackTrace) {
|
||||
_debugProfileLoadFailure(
|
||||
scope: 'detailHydrate',
|
||||
userId: userId,
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _hydrateRoomUserCard({
|
||||
required RoomUserCardRes? card,
|
||||
required String userId,
|
||||
required int requestSerial,
|
||||
}) async {
|
||||
try {
|
||||
final hydratedCard = await _withCurrentVipLevelForCard(card, userId);
|
||||
if (requestSerial != _userCardRequestSerial || hydratedCard == null) {
|
||||
return;
|
||||
}
|
||||
userCardInfo = hydratedCard;
|
||||
userCardLoadError = null;
|
||||
notifyListeners();
|
||||
} catch (error, stackTrace) {
|
||||
_debugProfileLoadFailure(
|
||||
scope: 'roomCardHydrate',
|
||||
userId: userId,
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void clearRoomUserCard() {
|
||||
_userCardRequestSerial++;
|
||||
userCardInfo = null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user