getUserStatus method

Future<V2TimValueCallback<List<V2TimUserStatus>>> getUserStatus({
  1. required List<String> userIDList,
})

Implementation

Future<V2TimValueCallback<List<V2TimUserStatus>>> getUserStatus({
  required List<String> userIDList,
}) async {
  try {
    final res = await wrappedPromiseToFuture(V2TIMManagerWeb.timWeb!
        .getUserStatus(mapToJSObj({"userIDList": userIDList})));
    final code = res.code;
    if (code == 0) {
      final successUserList = jsToMap(res.data)["successUserList"] as List;
      // final failureUserList = jsToMap(res.data)["failureUserList"];
      final formatedUserList = successUserList.map((e) {
        final item = jsToMap(e);
        return {
          "userID": item["userID"],
          "statusType": item["statusType"],
          "customStatus": item["customStatus"]
        };
      }).toList();

      return CommonUtils.returnSuccess<List<V2TimUserStatus>>(
          formatedUserList);
    } else {
      return CommonUtils.returnErrorForValueCb<List<V2TimUserStatus>>(
          'getUserStatus failed');
    }
  } catch (error) {
    return CommonUtils.returnErrorForValueCb<List<V2TimUserStatus>>(
        error.toString());
  }
}