public MessagesPage(int dialogId, MessagesManager messagesManager, DialogsManager dialogsManager) { this.dialogId = dialogId; this.messagesManager = messagesManager; this.dialogsManager = dialogsManager; NavigationPage.SetHasNavigationBar(this, false); SetBinding(RotaryFocusObjectProperty, new Binding { Source = messagesListView }); messagesListView.ItemsSource = messagesManager.GetMessages(dialogId); absoluteLayout.Children.Add(messagesListView); absoluteLayout.Children.Add(popupEntryView); absoluteLayout.Children.Add(activityIndicator); Content = absoluteLayout; swipeLeftRecognizer.Command = new Command(OpenKeyboard); swipeRightRecognizer.Command = new Command(OnOpenRecorder); messagesListView.GestureRecognizers.Add(swipeLeftRecognizer); messagesListView.GestureRecognizers.Add(swipeRightRecognizer); messagesListView.ItemTapped += OnItemTapped; messagesListView.ItemLongPressed += OnItemLongPressed; messagesListView.ItemAppearing += OnLoadMoreMessages; popupEntryView.Completed += OnTextCompleted; if (dialogsManager.GetIsInitRequired(this.dialogId)) { Appearing += OnConstructor; } }
public override Task <GetMessagesResponse> Handle(EmptyData _) { if (CurrentUser == null) { throw new HttpException(401); } var offsetString = Request.QueryString["offset"]; int offset; if (offsetString == null || !int.TryParse(offsetString, out offset)) { offset = 0; } else if (offset < 0) { throw new HttpException(400); } var countString = Request.QueryString["count"]; int count; if (countString == null || !int.TryParse(countString, out count)) { count = 10; } else if (count <= 0 || count > 100) { throw new HttpException(400); } var messages = messagesManager.GetMessages(offset, count); return(Task.FromResult(new GetMessagesResponse { Messages = messages .Select(m => new PostMessageResponse { Id = m.Id, Message = m.Text, AuthorId = m.AuthorId }) .ToList() })); }