public override async void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            var linearLayoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager();

            var totalItemCount  = linearLayoutManager.ItemCount;
            var lastVisibleItem = linearLayoutManager.FindLastVisibleItemPosition();

            if (!_isBusy && totalItemCount <= (lastVisibleItem + VisibleThreshold))
            {
                _isBusy = true;

                await _onScrolled.RunAsync();

                _isBusy = false;
            }
        }
        private async Task <IList <ChatMessageModel> > TryLoadLatestMessagesAsync(
            string chatId,
            string oldestMessageId,
            DateTimeOffset oldestMessageDate)
        {
            var messages = default(IList <ChatMessageModel>);

            try
            {
                var query = new MessagesQuery
                {
                    ChannelId    = chatId,
                    FromId       = oldestMessageId,
                    FromDateTime = oldestMessageDate
                };
                messages = await _getMessagesAsync.RunAsync(query).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(messages);
        }