Use loadChats instead of getChats in examples.
This commit is contained in:
parent
c35321b98e
commit
b002c2d4a8
@ -237,7 +237,7 @@ namespace TdExample
|
|||||||
_gotAuthorization.Reset();
|
_gotAuthorization.Reset();
|
||||||
_gotAuthorization.WaitOne();
|
_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)
|
while (_haveAuthorization)
|
||||||
{
|
{
|
||||||
GetCommand();
|
GetCommand();
|
||||||
|
@ -249,27 +249,20 @@ public final class Example {
|
|||||||
synchronized (mainChatList) {
|
synchronized (mainChatList) {
|
||||||
if (!haveFullMainChatList && limit > mainChatList.size()) {
|
if (!haveFullMainChatList && limit > mainChatList.size()) {
|
||||||
// send GetChats request if there are some unknown chats and have not enough known chats
|
// send GetChats request if there are some unknown chats and have not enough known chats
|
||||||
long offsetOrder = Long.MAX_VALUE;
|
client.send(new TdApi.LoadChats(new TdApi.ChatListMain(), limit - mainChatList.size()), new Client.ResultHandler() {
|
||||||
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() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onResult(TdApi.Object object) {
|
public void onResult(TdApi.Object object) {
|
||||||
switch (object.getConstructor()) {
|
switch (object.getConstructor()) {
|
||||||
case TdApi.Error.CONSTRUCTOR:
|
case TdApi.Error.CONSTRUCTOR:
|
||||||
System.err.println("Receive an error for GetChats:" + newLine + object);
|
if (((TdApi.Error) object).code == 404) {
|
||||||
break;
|
|
||||||
case TdApi.Chats.CONSTRUCTOR:
|
|
||||||
long[] chatIds = ((TdApi.Chats) object).chatIds;
|
|
||||||
if (chatIds.length == 0) {
|
|
||||||
synchronized (mainChatList) {
|
synchronized (mainChatList) {
|
||||||
haveFullMainChatList = true;
|
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
|
// chats had already been received through updates, let's retry request
|
||||||
getMainChatList(limit);
|
getMainChatList(limit);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user