feat:完成消息撤回后本地删除消息等操作

This commit is contained in:
Max
2023-12-12 10:50:07 +08:00
parent cfe2a45e4b
commit dc46c16f3e
4 changed files with 20 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum;
import com.netease.nimlib.sdk.msg.model.RecentContact;
import com.netease.nimlib.sdk.msg.model.RevokeMsgNotification;
import com.nnbc123.core.activity.event.ActivityEvent;
import com.nnbc123.core.auth.AuthModel;
import com.nnbc123.core.event.RoomInviteEvent;
@@ -80,6 +81,7 @@ public class IMMessageManager {
registerMsgStatusObserver();
registerRevokeMessageObserver();
// pullMessageHistory();
}
@@ -96,6 +98,20 @@ public class IMMessageManager {
msgStatusObserver, true);
}
private void registerRevokeMessageObserver() {
Observer<RevokeMsgNotification> revokeMessageObserver = new Observer<RevokeMsgNotification>() {
@Override
public void onEvent(RevokeMsgNotification notification) {
if (notification == null || notification.getMessage() == null) {
return;
}
IMMessage message = notification.getMessage();
NIMClient.getService(MsgService.class).deleteRecentContact2(message.getSessionId(), message.getSessionType());
}
};
NIMClient.getService(MsgServiceObserve.class).observeRevokeMessage(revokeMessageObserver, true);
}
private void registerRecentContactObserver() {
//会话改变监听
Observer<List<RecentContact>> recentContactObserver = (Observer<List<RecentContact>>) recentContacts -> {