fetchOwnInfo method

Future<ChatUserInfo?> fetchOwnInfo(
  1. {int expireTime = 0}
)

Gets the current user's attributes from the server.

Param expireTime The time period(seconds) when the user attributes in the cache expire. If the interval between two callers is less than or equal to the value you set in the parameter, user attributes are obtained directly from the local cache; otherwise, they are obtained from the server. For example, if you set this parameter to 120(2 minutes), once this method is called again within 2 minutes, the SDK returns the attributes obtained last time.

Return The user properties that are obtained. See ChatUserInfo.

Throws A description of the exception. See ChatError.

Implementation

Future<ChatUserInfo?> fetchOwnInfo({int expireTime = 0}) async {
  String? currentUser = await ChatClient.getInstance.getCurrentUserId();
  if (currentUser != null) {
    try {
      Map<String, ChatUserInfo> ret = await fetchUserInfoById(
        [currentUser],
        expireTime: expireTime,
      );
      _effectiveUserInfoMap[ret.values.first.userId] = ret.values.first;
      return ret.values.first;
    } on ChatError catch (e) {
      throw e;
    }
  }
  return null;
}