Browse Source

Merge remote-tracking branch 'origin/wr_202303' into wr_202303

wr_202303
wurong 4 months ago
parent
commit
04707d4fba
  1. 19
      lib/im/chat_details_page.dart

19
lib/im/chat_details_page.dart

@ -12,9 +12,12 @@ import 'package:huixiang/im/database/message.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/data/im_user.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter/cupertino.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:image_pickers/image_pickers.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../community/release_dynamic.dart';
import '../../generated/l10n.dart';
@ -69,7 +72,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
// SmartDialog.showToast("聊天 $txt", alignment: Alignment.center);
}
RefreshController refreshController = RefreshController();
List<Message> messages = [];
int page = 0;
loadMessageList() async {
ImUser imUser = await hxDatabase.queryImUserById(_toUser.mid);
@ -80,7 +85,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
selfUserId = (await SharedPreferences.getInstance()).getString("userId");
// unread msg 2 read state
await hxDatabase.readMessage(selfUserId, _toUser.mid);
messages = await hxDatabase.queryUList(_toUser.mid, pageSize: 100);
await refresh();
socketClient.addCallback(_toUser.mid, (Message message) {
messages.insert(0, message);
@ -119,6 +124,18 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
});
}
refresh() async {
page += 1;
List<Message> messagePage = await hxDatabase.queryUList(_toUser.mid, page: page, pageSize: 10);
if (page == 1) {
messages = messagePage;
} else {
messages.addAll(messagePage);
}
refreshController.refreshCompleted();
return;
}
///
queryUser() async {
final SharedPreferences value = await SharedPreferences.getInstance();

Loading…
Cancel
Save