/// <summary> /// Togle visibility of invite list /// </summary> async void inviteListButtonClick() { ShowInviteList = !ShowInviteList; if (ShowInviteList) { //Load contacts ContactsInviteList = new ContactsListViewModel(await UnitOfWork.GetUsersInfo(new List <int>(UnitOfWork.User.contactsIdList)), false, true); } }
async void loadInfo(Group group) { //Set group info GroupInfo = group; //add contacts to contact list all members list if (GroupInfo.MembersIdList != null) { var membersInfo = await UnitOfWork.GetUsersInfo(new List <int>(GroupInfo.MembersIdList)); ContactsList = new ContactsListViewModel(membersInfo, true, false, AreYouAdmin); } //Load shared files List <string> filesPath = new List <string>(); var messages = UnitOfWork.Database.MessagesTableRepo.Find(MessagesTableFields.ReceiverId.ToString(), GroupInfo.Id.ToString()); foreach (var mess in messages) { if (mess.AttachmentsList.Count != 0) { foreach (var attachment in mess.AttachmentsList) { filesPath.Add(attachment); } } } foreach (var file in await UnitOfWork.GetFilesByName(filesPath)) { //Becouse Items is ObservableCollection we should update elements from the main thread await App.Current.Dispatcher.Invoke(async() => { SharedMedia.Items.Add(new FilesListItemViewModel(file, false, false)); }); } //Update UI OnPropertyChanged("GroupName"); OnPropertyChanged("IsYourGroup"); OnPropertyChanged("IsOnline"); OnPropertyChanged("AreYouAdmin"); }
public SearchResultsViewModel() { //Setup handlers ApplicationService.GetChatViewModel.OnUsersSearchResultChanged((sender, args) => onUsersSearchResultChanged(args)); ApplicationService.GetChatViewModel.OnGroupSearchResultChanged((sender, args) => onGroupSearchResultChanged(args)); //Set results var users = ApplicationService.UsersSearchResult; var groups = ApplicationService.GroupsSearchResult; if (users != null) { UsersSearchResults = new ContactsListViewModel(users); } if (groups != null) { GroupsSearchResults = new GroupsListViewModel(groups); } }
async void loadInfo(Contact contact) { if (contact == null) { return; } //Set user info UserInfo = contact; //If it's your account, than add contacts list if (IsYourAccaunt) { //Add on user data changed handler UnitOfWork.AddUserInfoUpdatedHandler((sender, args) => OnUserUpdates(sender, args)); //Load contacts info var contactsList = await UnitOfWork.GetUsersInfo(new List <int>(UnitOfWork.User.contactsIdList)); if (contactsList != null) { ContactsList = new ContactsListViewModel(contactsList, false, false, false, true); } } //If it's not your account, add groups list else { //Make request to the server and get groups list GroupsList = new GroupsListViewModel(await UnitOfWork.GetUserGroupsInfo(UserInfo)); } //Update UI OnPropertyChanged("UserName"); OnPropertyChanged("Bio"); OnPropertyChanged("Email"); OnPropertyChanged("IsYourContact"); OnPropertyChanged("IsYourAccaunt"); OnPropertyChanged("GroupsList"); }
void onUsersSearchResultChanged(List <Contact> dataChanged) { UsersSearchResults = new ContactsListViewModel(dataChanged); }