diff --git a/lib/im/database/hx_database.dart b/lib/im/database/hx_database.dart index 8c576253..f8ca35c1 100644 --- a/lib/im/database/hx_database.dart +++ b/lib/im/database/hx_database.dart @@ -1,4 +1,5 @@ import 'package:flutter/cupertino.dart'; +import 'package:huixiang/constant.dart'; import 'package:huixiang/im/database/message.dart'; import 'package:huixiang/im/database/migration.dart'; import 'package:sqflite/sqflite.dart'; diff --git a/lib/im/im_view/im_page.dart b/lib/im/im_view/im_page.dart index b14a4687..b5e9bafe 100644 --- a/lib/im/im_view/im_page.dart +++ b/lib/im/im_view/im_page.dart @@ -232,6 +232,9 @@ class _IMPage extends State implements OnChatMessage { ///批量查询用户信息 queryMemberInfo(List mids) async { + if (mids.isEmpty) { + return; + } BaseData> baseData = await apiService.memberInfoByIds({ "mids": mids, }).catchError((error) { @@ -239,17 +242,19 @@ class _IMPage extends State implements OnChatMessage { alignment: Alignment.center); }); if (baseData != null && baseData.isSuccess) { - baseData.data.forEach((element) async { - await hxDatabase.insertOrUpdateImUser(element.toJson()); - }); - contactMap = baseData.data.lGroupBy((p0) => p0.mid).mGroupItem; - setState(() {}); + if (baseData.data.isNotEmpty) { + baseData.data.forEach((element) async { + await hxDatabase.insertOrUpdateImUser(element.toJson()); + }); + contactMap = baseData.data.lGroupBy((p0) => p0.mid).mGroupItem; + setState(() {}); + } } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } } - RefreshController _refreshController = RefreshController(); + final RefreshController _refreshController = RefreshController(); @override Widget build(BuildContext context) {