/// <summary> /// Load newer messages /// </summary> private async void LoadNewerMessages() { try { // Check if there are newer messages Message last = (MessageList.Items.Last() as MessageContainer)?.Message; if (last != null && LocalState.RPC.ContainsKey(ChannelId) && last.Id != LocalState.RPC[ChannelId].LastMessageId) { // Show loading indicator MessagesLoading.Visibility = Visibility.Visible; // Prevent a second call DisableLoadingMessages = true; // Get Messages List <MessageContainer> messages = await MessageManager.ConvertMessage( (await RESTCalls.GetChannelMessagesAfter(ChannelId, (MessageList.Items.LastOrDefault(x => (x as MessageContainer).Message != null) as MessageContainer).Message.Id)).ToList()); _messageStacker.ItemsUpdatingScrollMode = ItemsUpdatingScrollMode.KeepScrollOffset; // Display messages AddMessages(Position.After, false, messages, _outofboundsNewMessage); //if there is an out of bounds new message, show the indicator. Otherwise, don't. _messageStacker.ItemsUpdatingScrollMode = ItemsUpdatingScrollMode.KeepLastItemInView; // Hide loading indicator MessagesLoading.Visibility = Visibility.Collapsed; // Buffer perioud for loading more messages await Task.Delay(1000); DisableLoadingMessages = false; } } catch { // ignored } }