进房历史消息查询逻辑优化

This commit is contained in:
huangjian
2022-05-13 11:58:55 +08:00
parent 44e90490af
commit 243f57a360
2 changed files with 12 additions and 5 deletions

View File

@@ -262,7 +262,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
// 刷新礼物列表,获取房间专属礼物列表
GiftModel.get().refreshGiftList(AvRoomDataManager.get().roomUid.toString()).subscribe()
checkFollowOwner()
mvpPresenter?.loadMessageHistory()
mvpPresenter?.loadMessageHistory(AvRoomDataManager.get().clearScreenTime)
mvpPresenter?.loadRoomRank()
//最小化恢复时,更新礼物值
if (isRoomMin) {

View File

@@ -511,7 +511,7 @@ public class BaseRoomPresenter<V extends IBaseRoomView> extends BaseMvpPresenter
/**
* 公屏历史消息
*/
public void loadMessageHistory() {
public void loadMessageHistory(long startTime) {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (roomInfo == null) return;
@@ -519,18 +519,25 @@ public class BaseRoomPresenter<V extends IBaseRoomView> extends BaseMvpPresenter
int count = 10;
InitInfo initInfo = InitialModel.get().getCacheInitInfo();
if (initInfo != null) count = initInfo.getRoomMessageCount();
int finalCount = count;
NIMClient.getService(ChatRoomService.class)
.pullMessageHistoryExType(
String.valueOf(roomInfo.getRoomId()),
AvRoomDataManager.get().clearScreenTime,
startTime,
count,
AvRoomDataManager.get().clearScreenTime == 0 ? QueryDirectionEnum.QUERY_OLD : QueryDirectionEnum.QUERY_NEW,
startTime == 0 ? QueryDirectionEnum.QUERY_OLD : QueryDirectionEnum.QUERY_NEW,
new MsgTypeEnum[]{MsgTypeEnum.text})
.setCallback(new RequestCallbackWrapper<List<ChatRoomMessage>>() {
@Override
public void onResult(int code, List<ChatRoomMessage> result, Throwable exception) {
if (code == ResponseCode.RES_SUCCESS && result != null && result.size() > 0) {
Collections.reverse(result);
if (startTime != 0 && result.size() >= finalCount) {
loadMessageHistory(0);
return;
}
if (startTime == 0) {
Collections.reverse(result);
}
if (getMvpView() != null) {
getMvpView().showMessageHistory(result);
}