public void RemoveDuplicateIDs() { var set = new MessageSet(); set.Add(1); set.Add(1); Assert.AreEqual("1", set.ToString()); }
public void RemoveID() { var set = new MessageSet(); set.Add(1); set.Add(7); set.Remove(1); Assert.AreEqual("7", set.ToString()); }
public void RangesAndIDs() { var set = new MessageSet(); set.Add(1); set.AddRange(3, 5); set.Add(7); Assert.AreEqual("1,3:5,7", set.ToString()); }
public void RangesDoNotOverlapIDs() { var set = new MessageSet(); set.Add(2); set.AddRange(1, 3); Assert.AreEqual("1:3", set.ToString()); }
//private async void FetchHistory() //{ // LoadingVisibility = true; // FetchHistoryVisibility = false; // MessageSet.Clear(); // var result = await new MalMessageDetailsQuery().GetMessagesInThread(_prevMsg); // result.Reverse(); //newest first // _messageThreads[_prevMsg.ThreadId] = result; // MessageSet.AddRange(result.Select(model => new MessageEntry(model))); // LoadingVisibility = false; //} private async void SendMessage() { IsSendButtonEnabled = false; if (!string.IsNullOrEmpty(MessageText)) { if (_prevArgs == null || _prevArgs.WorkMode == MessageDetailsWorkMode.Message) { if (_newMessage) { if (MessageSubject == null || MessageTarget == null) { IsSendButtonEnabled = true; return; } if (await new SendMessageQuery().SendMessage(MessageSubject, MessageText, MessageTarget)) { try { await Task.Delay(500); //let mal process the thing var message = new MalMessageModel(); var id = await new MalMessagesQuery().GetFirstSentMessageId(); message.Id = id; message = await new MalMessageDetailsQuery().GetMessageDetails(message, true); message.Target = MessageTarget; message.Sender = Credentials.UserName; message.IsRead = true; message.Date = DateTime.Now.ToString("d"); message.Subject = MessageSubject; MessageThreads[message.ThreadId] = new List <MalMessageModel> { message }; _prevMsg = message; _newMessage = false; NewMessageFieldsVisibility = false; ViewModelLocator.GeneralMain.CurrentOffStatus = $"{message.Sender} - {message.Subject}"; MessageSet.Clear(); MessageSet.AddRange(new[] { message }); MessageText = ""; MessageSubject = ""; MessageTarget = ""; } catch (Exception) { ResourceLocator.MessageDialogProvider.ShowMessageDialog("Unable to send this message.", "Error"); } } else { ResourceLocator.MessageDialogProvider.ShowMessageDialog("Unable to send this message.", "Error"); } IsSendButtonEnabled = true; return; } if ( await new SendMessageQuery().SendMessage(_prevMsg.Subject, MessageText, _prevMsg.Target, _prevMsg.ThreadId, _prevMsg.ReplyId)) { var message = new MalMessageModel { Subject = _prevMsg.Subject, Content = MessageText, Date = DateTime.Now.ToString("d"), Id = "0", Sender = Credentials.UserName, Target = _prevMsg.Target, ThreadId = _prevMsg.ThreadId, ReplyId = _prevMsg.ReplyId }; if (MessageThreads.ContainsKey(_prevMsg.ThreadId)) { MessageThreads[_prevMsg.ThreadId].Insert(0, message); } else { MessageThreads[_prevMsg.ThreadId] = new List <MalMessageModel> { _prevMsg, message }; } MessageSet.AddRange(new[] { message }); MessageText = ""; MessageSubject = ""; MessageTarget = ""; RaisePropertyChanged(() => MessageText); } else { ResourceLocator.MessageDialogProvider.ShowMessageDialog("Unable to send this message.", "Error"); } } else //comment { var comment = _prevArgs.Arg as MalComment; if (await ProfileCommentQueries.SendCommentReply(comment.ComToCom.Split('=').Last(), MessageText)) { MessageSet.Add( new MalMessageModel { Content = MessageText, Sender = Credentials.UserName, Date = DateTime.Now.ToString("d") } ); MessageText = ""; RaisePropertyChanged(() => MessageSet); RaisePropertyChanged(() => MessageText); } } } IsSendButtonEnabled = true; }