private async Task LoadHistory() { Console.WriteLine("STATUS: Loading history"); List <ChatData> historyList = null; try { historyList = await FileService.LoadHistoryAsync(); } catch (HistoryNotFoundException ex) { Console.WriteLine($"ERROR: {ex.Message}"); } if (historyList != null) { Application.Current.Dispatcher.Invoke(() => { foreach (ChatData chatData in historyList) { ChatHistoryList.Add(chatData); } UpdateSearch(); }); Console.WriteLine("RESULT: Chat history successfully loaded"); } else { Console.WriteLine("RESULT: Chat history failed to load"); } }
private void ViewChatFromHistory(object match) { Console.WriteLine("STATUS: Getting chat from history"); ChatData chatData = ChatHistoryList.Single(chat => chat.SearchString == (string)match); OnlineViewModel.LoadChatAsHistory(chatData); }
internal async void ClosingApp(object sender, CancelEventArgs e) { Console.WriteLine("STATUS: MenuViewModel closing"); await Connection.SendNetworkData(new NetworkData(User, NetworkDataType.Response, "", ResponseType.Disconnect)); Connection.CloseConnection(); await FileService.WriteHistoryAsync(ChatHistoryList.ToList()); }
internal void AddChatToHistory(ChatData chatData) { ChatHistoryList.Insert(0, chatData); UpdateSearch(); }