/// <summary> /// Update typing list /// </summary> public async void UpdateTyping() { string typingString = ""; List <string> NamesTyping = new List <string>(); // If the channel exists if (ChannelId != null) { // Check if typer list includes this channel if (LocalState.Typers.ContainsKey(ChannelId)) { // Get all typers in this channel foreach (KeyValuePair <string, DispatcherTimer> typer in LocalState.Typers[ChannelId]) { if (CurrentGuildIsDM) { // Add name to list NamesTyping.Add(LocalState.DMs[ChannelId].Users .FirstOrDefault(m => m.Id == typer.Key).Username); } else { // Get member GuildMember member; if (LocalState.Guilds[CurrentGuildId].members.ContainsKey(typer.Key)) { member = LocalState.Guilds[CurrentGuildId].members[typer.Key]; } else { member = new GuildMember() { User = await RESTCalls.GetUser(typer.Key) }; } // Get name or nickname string displayedName = member.User.Username; if (member.Nick != null) { displayedName = member.Nick; } // Add name/nickname to list NamesTyping.Add(displayedName); } } } } int displayedTyperCounter = NamesTyping.Count(); for (int i = 0; i < displayedTyperCounter; i++) { //TODO: Fix translate if (i == 0) { typingString += NamesTyping.ElementAt(i); //first element, no prefix } else if (i == 2 && i == displayedTyperCounter) { typingString += " " + App.GetString("/Main/TypingAnd") + " " + " " + NamesTyping.ElementAt(i); //last element out of 2, prefix = "and" } else if (i == displayedTyperCounter) { typingString += ", " + App.GetString("/Main/TypingAnd") + NamesTyping.ElementAt(i); //last element out of 2, prefix = "and" WITH OXFORD COMMA } else { typingString += ", " + NamesTyping.ElementAt(i); //intermediary element, prefix = comma } } // Add "is typing" or "are typing" if (displayedTyperCounter > 1) { typingString += " " + App.GetString("/Main/TypingPlural"); } else { typingString += " " + App.GetString("/Main/TypingSingular"); } // Update UI text TypingIndicator.Text = typingString; // Show or hide UI if (displayedTyperCounter == 0) { // Hide TypingStackPanel.Fade(0, 300).Start(); } else { // Show TypingStackPanel.Fade(1, 300).Start(); } }