/* ---------- Internal method to process new events/messages/conversations/... ----------- */ private void InitializeDb() { Conversations.Clear(); using (var db = new LiteDatabase(DbPath)) { var users = db.GetCollection <User>("users"); var conversations = db.GetCollection <Conversation>("conversations"); var messages = db.GetCollection <Message>("messages"); var events = db.GetCollection <ConversationEvent>("events"); users.EnsureIndex(x => x.Id, true); conversations.EnsureIndex(x => x.Id, true); // First retrieve all the conversations conversations.FindAll().ToList().ForEach(Conversations.Add); // Then populate them with messages and events foreach (Message msg in messages.FindAll()) { Conversations.Where(x => x.Id.Equals(msg.ConversationId)).First().AddItem(msg); } foreach (ConversationEvent evt in events.FindAll()) { Conversations.Where(x => x.Id.Equals(evt.ConversationId)).First().AddItem(evt); } } }
public void CloseClient() { thread.Abort(); thread.Join(500); Users.Clear(); Conversations.Clear(); client.Close(); }
public void Terminate() { Messages.Clear(); messageUIDS.Clear(); Conversations.Clear(); ConversationByCID.Clear(); visibilityByConversationID.Clear(); ConversationFilter = string.Empty; }
public async Task LoadDataAsync() { var data = await _conversationService.GetAllConversationsForUser(); Conversations.Clear(); foreach (var item in data) { Conversations.Add(new ConversationViewModel(item)); } SelectedConversation = Conversations.FirstOrDefault(); }
public void GetAllConversations() { App.Current.Dispatcher.Invoke((Action) delegate { Conversations.Clear(); ConversationByCID.Clear(); CurrentConversation = null; }); WebSocket.Instance.GetAllConversations(); }
public void ReceivedUserConversations(List <Conversation> conversations) { App.Current.Dispatcher.Invoke((Action) delegate { CurrentConversation = null; ConversationFilter = string.Empty; Conversations.Clear(); ConversationByCID.Clear(); foreach (var conversation in conversations) { AddConversationToView(conversation); } }); }
public void OnReceivedAllConversations(List <Conversation> conversations) { App.Current.Dispatcher.BeginInvoke((Action) delegate { CurrentConversation = null; Conversations.Clear(); ConversationByCID.Clear(); var filteredConverstions = conversations.Where(w => w.ConvName.ToLower().Contains(ConversationFilter.ToLower())); foreach (var conversation in filteredConverstions) { AddConversationToView(conversation); } }); }