Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

queryMessagesWithLimit 获取消息不准确 #213

Closed
nicecui opened this issue Apr 19, 2017 · 2 comments
Closed

queryMessagesWithLimit 获取消息不准确 #213

nicecui opened this issue Apr 19, 2017 · 2 comments
Assignees
Labels
bug Something isn't working resolved

Comments

@nicecui
Copy link

nicecui commented Apr 19, 2017

https://forum.leancloud.cn/t/querymessagesbeforeid-ios-bug/14340

重现步骤:

  1. 进入一个对话,使用 REST API 发 5 次消息,消息内容分别为:1, 2, 3, 4, 5
  2. 杀掉应用,使用 REST API 发 20 次消息,从 6 到 25
  3. 在对话中添加如下代码:
[self.conversation queryMessagesWithLimit:5 callback:^(NSArray * _Nullable objects, NSError * _Nullable error) {
        if (!error) {
            NSLog(@"第一次查出来 %@", objects);
            for (AVIMTextMessage *m1 in objects) {
                NSLog(@"%@", m1.text);
            }
            AVIMTextMessage *lastMessage = objects[0];
            [self.conversation queryMessagesBeforeId:lastMessage.messageId timestamp:lastMessage.sendTimestamp limit:5 callback:^(NSArray * _Nullable objects2, NSError * _Nullable error) {
                NSLog(@"第二次查出来 %@", objects);
                for (AVIMTextMessage *m in objects2) {
                    NSLog(@"%@", m.text);
                }
            }];
        }
    }];
  1. 运行应用,进入对话,可以看到:

第一次查出:

2017-04-19 17:32:51.160208+0800 LeanChatCui[6043:2295880] 21
2017-04-19 17:32:51.160428+0800 LeanChatCui[6043:2295880] 22
2017-04-19 17:32:51.160720+0800 LeanChatCui[6043:2295880] 23
2017-04-19 17:32:51.160903+0800 LeanChatCui[6043:2295880] 24
2017-04-19 17:32:51.161270+0800 LeanChatCui[6043:2295880] 25

第二次应该查出 16 到 20,却返回了如下结果:

2017-04-19 17:32:53.374585+0800 LeanChatCui[6043:2295880] 333333333333333333333333333333333333333333333333333333(这个是之前对话的消息)
2017-04-19 17:32:53.374978+0800 LeanChatCui[6043:2295880] 1
2017-04-19 17:32:53.375179+0800 LeanChatCui[6043:2295880] 2
2017-04-19 17:32:53.375363+0800 LeanChatCui[6043:2295880] 3
2017-04-19 17:32:53.375470+0800 LeanChatCui[6043:2295880] (null)
@nicecui nicecui added the bug Something isn't working label Apr 19, 2017
@tang3w
Copy link
Contributor

tang3w commented Apr 21, 2017

这个问题是由 https://github.com/leancloud/ios-sdk/issues/210 这个提议导致的,过早优化是万恶之源。

@tang3w
Copy link
Contributor

tang3w commented Apr 25, 2017

Solved in 4.3.0

@tang3w tang3w closed this as completed Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved
Projects
None yet
Development

No branches or pull requests

2 participants