wildfirechat / android-chat

即时通讯,聊天,野火IMAndroid客户端,支持Android 4.x —— 最新
http://docs.wildfirechat.cn
Other
2.52k stars 878 forks source link

设置草稿或者去除草稿,ConversationInfo的timestamp字段没有改变。 #813

Closed gnmmdk closed 1 year ago

gnmmdk commented 1 year ago

现有的野火设置完草稿后,顺序会改变,但是不管有没有设置草稿,或者修改草稿ConversationInfo的timestamp字段一直没有改变,但是iOS端的timestamp是有变化的。 我们需要在设置完草稿后,根据timestamp去做一些自己的排序逻辑。

下图首次设置了草稿的时间戳, image 下图修改草稿后的时间戳: image

imndx commented 1 year ago

你好,最新代码,我们在设置草稿(setConversationDraft)前后,加了日志,确定timestamp是更新了的,请用最新代码确认下

gnmmdk commented 1 year ago

我也是使用最新代码(8/28号的mars库),一样在setConversationDraft前后,timestamp是没有更新的。试了两款机型华为和oppo,都是一样。

imndx commented 1 year ago

ChatManager.java里面,直接在setConversationDraft添加日志确认下:

   public void setConversationDraft(Conversation conversation, @Nullable String draft) {
        if (conversation == null) {
            return;
        }

        if (!checkRemoteService()) {
            return;
        }

        try {
            ConversationInfo conversationInfo = getConversation(conversation);
            if (conversationInfo == null || TextUtils.equals(draft, conversationInfo.draft)) {
                return;
            }
            Log.d(TAG, "before: " + conversationInfo.timestamp);
            mClient.setConversationDraft(conversation.type.ordinal(), conversation.target, conversation.line, draft);
        } catch (RemoteException e) {
            e.printStackTrace();
        }

        ConversationInfo conversationInfo = getConversation(conversation);
        Log.d(TAG, "after: " + conversationInfo.timestamp);
        for (OnConversationInfoUpdateListener listener : conversationInfoUpdateListeners) {
            listener.onConversationDraftUpdate(conversationInfo, draft);
        }
    }
gnmmdk commented 1 year ago

image image

gnmmdk commented 1 year ago

我是先输入“急急急”,然后退出聊天页面,再次进入,在原本草稿的基础上改为“急急”,然后退出聊天页面,时间戳并没有改变。这次是使用野火demo加日志查看,最新的代码。

imndx commented 1 year ago

ChatManager.java里面,直接在setConversationDraft添加日志确认下:

   public void setConversationDraft(Conversation conversation, @Nullable String draft) {
        if (conversation == null) {
            return;
        }

        if (!checkRemoteService()) {
            return;
        }

        try {
            ConversationInfo conversationInfo = getConversation(conversation);
            if (conversationInfo == null || TextUtils.equals(draft, conversationInfo.draft)) {
                return;
            }
            Log.d(TAG, "before: " + conversationInfo.timestamp);
            mClient.setConversationDraft(conversation.type.ordinal(), conversation.target, conversation.line, draft);
        } catch (RemoteException e) {
            e.printStackTrace();
        }

        ConversationInfo conversationInfo = getConversation(conversation);
        Log.d(TAG, "after: " + conversationInfo.timestamp);
        for (OnConversationInfoUpdateListener listener : conversationInfoUpdateListeners) {
            listener.onConversationDraftUpdate(conversationInfo, draft);
        }
    }

你这样,先确认设置草稿,时间戳是否更新?

你上面测试的变更草稿操作

gnmmdk commented 1 year ago

image

gnmmdk commented 1 year ago

设置了,一样的时间戳。你是使用什么手机?

imndx commented 1 year ago

不好意思,我上面说错了,确实如你所说,设置草稿时,会话的时间戳没有更新。

设置草稿时,会话的时间戳保持不变的原因是:会话列表要显示正确的最后一条消息的时间。

请问你们具体是什么需求?现在会话列表的排序逻辑什么地方不能满足需求?

gnmmdk commented 1 year ago

我们有一个自己的置顶功能(非野火的置顶),置顶的会话保存在本地数据库。我们自己的置顶也需要对草稿进行排序。因此想利用会话的timestamp这个来排序。我们看了iOS草稿改变的时候,这个值会改变,而Android不会变,因此想问下能不能实现。

imndx commented 1 year ago

这个问题,会保持当前状态,如果你们确实需要修改的话,请修改下面的代码,草稿为空且有最后一条消息时,才使用最后一条消息的时间戳作为会话的时间戳:

https://github.com/wildfirechat/android-chat/blob/e3f8dc5caea5c5da4788b534d8b3f538e32b17f3/client/src/main/java/cn/wildfirechat/client/ClientService.java#L673-L691

gnmmdk commented 12 months ago

这里我需要使用哪个时间?

imndx commented 12 months ago

这里我需要使用哪个时间?

info.timestamp = protoInfo.getTimestamp();