Merge branch 'feature' of gitea.haiyihy.com:hy/chatapp3-flutter into feature
This commit is contained in:
commit
bb9b92230b
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:yumi/app_localizations.dart';
|
import 'package:yumi/app_localizations.dart';
|
||||||
@ -170,19 +172,20 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
|||||||
final loadedProfile = await SCAccountRepository().loadUserInfo(
|
final loadedProfile = await SCAccountRepository().loadUserInfo(
|
||||||
normalizedUserId,
|
normalizedUserId,
|
||||||
);
|
);
|
||||||
var mergedProfile = await _withCurrentVipLevel(
|
|
||||||
loadedProfile,
|
|
||||||
normalizedUserId,
|
|
||||||
);
|
|
||||||
mergedProfile = await _withCpCabinProfiles(
|
|
||||||
mergedProfile,
|
|
||||||
normalizedUserId,
|
|
||||||
);
|
|
||||||
if (requestSerial != _userInfoRequestSerial) {
|
if (requestSerial != _userInfoRequestSerial) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
userProfile = mergedProfile;
|
userProfile = loadedProfile;
|
||||||
userProfileLoadError = null;
|
userProfileLoadError = null;
|
||||||
|
isUserProfileLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
unawaited(
|
||||||
|
_hydrateUserInfoById(
|
||||||
|
profile: loadedProfile,
|
||||||
|
userId: normalizedUserId,
|
||||||
|
requestSerial: requestSerial,
|
||||||
|
),
|
||||||
|
);
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
if (requestSerial != _userInfoRequestSerial) {
|
if (requestSerial != _userInfoRequestSerial) {
|
||||||
return;
|
return;
|
||||||
@ -196,7 +199,7 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
|||||||
stackTrace: stackTrace,
|
stackTrace: stackTrace,
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
if (requestSerial == _userInfoRequestSerial) {
|
if (requestSerial == _userInfoRequestSerial && isUserProfileLoading) {
|
||||||
isUserProfileLoading = false;
|
isUserProfileLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
@ -234,12 +237,20 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
|||||||
normalizedRoomId,
|
normalizedRoomId,
|
||||||
normalizedUserId,
|
normalizedUserId,
|
||||||
);
|
);
|
||||||
card = await _withCurrentVipLevelForCard(card, normalizedUserId);
|
|
||||||
if (requestSerial != _userCardRequestSerial) {
|
if (requestSerial != _userCardRequestSerial) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
userCardInfo = card;
|
userCardInfo = card;
|
||||||
userCardLoadError = null;
|
userCardLoadError = null;
|
||||||
|
isUserCardLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
unawaited(
|
||||||
|
_hydrateRoomUserCard(
|
||||||
|
card: card,
|
||||||
|
userId: normalizedUserId,
|
||||||
|
requestSerial: requestSerial,
|
||||||
|
),
|
||||||
|
);
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
if (requestSerial != _userCardRequestSerial) {
|
if (requestSerial != _userCardRequestSerial) {
|
||||||
return;
|
return;
|
||||||
@ -253,13 +264,60 @@ class SocialChatUserProfileManager extends ChangeNotifier {
|
|||||||
stackTrace: stackTrace,
|
stackTrace: stackTrace,
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
if (requestSerial == _userCardRequestSerial) {
|
if (requestSerial == _userCardRequestSerial && isUserCardLoading) {
|
||||||
isUserCardLoading = false;
|
isUserCardLoading = false;
|
||||||
notifyListeners();
|
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() {
|
void clearRoomUserCard() {
|
||||||
_userCardRequestSerial++;
|
_userCardRequestSerial++;
|
||||||
userCardInfo = null;
|
userCardInfo = null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user