ilyalatt / Telega

C# Telegram MTProto Client
https://ilyalatt.github.io/Telega/
MIT License
58 stars 15 forks source link

GetMessages and GetMessageById methods #48

Closed tarasverq closed 3 years ago

tarasverq commented 3 years ago

Hi Ilya!

Some new useful methods for library

ilyalatt commented 3 years ago

I've simplified the code. I am not sure that .OrderBy(x => x.Id) is needed. Are you sure that fetched messages are not sorted by id already?

tarasverq commented 3 years ago

I'm not sure about sorting, this was just to be sure.

By the way this approach will not work:

 var groupId = messages.Find(x => x.Id == messageId).Bind(x => x.GroupedId);
 return messages.Filter(x => x.GroupedId == groupId);

In case of single message groupId variable will be Option.None, so you will return all single messages near messageId. We should check groupId for None option.

ilyalatt commented 3 years ago

Yeah, but it is fixed already

ilyalatt commented 3 years ago

Can you verify that id's are ordered and the method works as expected?

tarasverq commented 3 years ago

checked: ids is in ascending order

ilyalatt commented 3 years ago

good