Exemple #1
0
        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");
            }
        }
Exemple #2
0
        private void ViewChatFromHistory(object match)
        {
            Console.WriteLine("STATUS: Getting chat from history");
            ChatData chatData = ChatHistoryList.Single(chat => chat.SearchString == (string)match);

            OnlineViewModel.LoadChatAsHistory(chatData);
        }
Exemple #3
0
        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());
        }
Exemple #4
0
 internal void AddChatToHistory(ChatData chatData)
 {
     ChatHistoryList.Insert(0, chatData);
     UpdateSearch();
 }