private async Task StartLoadingPrevTweets() { Status status = DisplayTweet.Model; IsLoadingPrevious = true; while (true) { if (status.InReplyToStatusID == 0) { break; } var inReplyTo = await Context.Twitter.Statuses.GetTweet(status.InReplyToStatusID, true); if (inReplyTo == null) { break; } var vm = new StatusViewModel(inReplyTo, Context, Configuration, ViewServiceRepository); await Dispatcher.RunAsync(() => PreviousConversationTweets.Insert(0, vm)); RaisePropertyChanged(nameof(PreviousConversationTweets)); status = inReplyTo; } await Task.WhenAll(PreviousConversationTweets.Select(s => s.LoadDataAsync())); IsLoadingPrevious = false; await Dispatcher.RunAsync(() => ScrollRequested?.Invoke(this, EventArgs.Empty)); }
public async Task OnLoad(object data) { IsLoadingPrevious = true; Message.WasRead = true; var userId = Message.Partner.Model.GetUserId(); var cacheMessages = await Cache.GetMessages(); var messages = cacheMessages.Where(m => m.Recipient == userId || m.Sender == userId) .Select(m => JsonConvert.DeserializeObject <DirectMessage>(m.Data)) .Where(m => m.GetMessageId() < Message.Id) .OrderBy(m => m.CreatedAt); foreach (var m in messages) { var msg = new MessageViewModel(m, Message.Context, Configuration, ViewServiceRepository) { WasRead = true }; await Dispatcher.RunAsync(() => PreviousMessages.Add(msg)); } RaisePropertyChanged(nameof(PreviousMessages)); IsLoadingPrevious = false; await Dispatcher.RunAsync(() => ScrollRequested?.Invoke(this, EventArgs.Empty)); }
public void ScrollToNextPage(double animationDuration = 0.5) { ScrollRequested?.Invoke(animationDuration); }