diff --git a/example/csharp/TdExample.cs b/example/csharp/TdExample.cs index 93de775d9..3b18f1dd9 100644 --- a/example/csharp/TdExample.cs +++ b/example/csharp/TdExample.cs @@ -237,7 +237,7 @@ namespace TdExample _gotAuthorization.Reset(); _gotAuthorization.WaitOne(); - _client.Send(new TdApi.GetChats(null, Int64.MaxValue, 0, 100), _defaultHandler); // preload main chat list + _client.Send(new TdApi.LoadChats(null, 100), _defaultHandler); // preload main chat list while (_haveAuthorization) { GetCommand(); diff --git a/example/java/org/drinkless/tdlib/example/Example.java b/example/java/org/drinkless/tdlib/example/Example.java index 804cf5df4..72569bafc 100644 --- a/example/java/org/drinkless/tdlib/example/Example.java +++ b/example/java/org/drinkless/tdlib/example/Example.java @@ -249,27 +249,20 @@ public final class Example { synchronized (mainChatList) { if (!haveFullMainChatList && limit > mainChatList.size()) { // send GetChats request if there are some unknown chats and have not enough known chats - long offsetOrder = Long.MAX_VALUE; - long offsetChatId = 0; - if (!mainChatList.isEmpty()) { - OrderedChat last = mainChatList.last(); - offsetOrder = last.position.order; - offsetChatId = last.chatId; - } - client.send(new TdApi.GetChats(new TdApi.ChatListMain(), offsetOrder, offsetChatId, limit - mainChatList.size()), new Client.ResultHandler() { + client.send(new TdApi.LoadChats(new TdApi.ChatListMain(), limit - mainChatList.size()), new Client.ResultHandler() { @Override public void onResult(TdApi.Object object) { switch (object.getConstructor()) { case TdApi.Error.CONSTRUCTOR: - System.err.println("Receive an error for GetChats:" + newLine + object); - break; - case TdApi.Chats.CONSTRUCTOR: - long[] chatIds = ((TdApi.Chats) object).chatIds; - if (chatIds.length == 0) { + if (((TdApi.Error) object).code == 404) { synchronized (mainChatList) { haveFullMainChatList = true; } + } else { + System.err.println("Receive an error for GetChats:" + newLine + object); } + break; + case TdApi.Ok.CONSTRUCTOR: // chats had already been received through updates, let's retry request getMainChatList(limit); break;