public AllowUsersViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator) { if (StateService.UsersRule is TLPrivacyValueAllowUsers) { Title = AppResources.AlwaysShare.ToLowerInvariant(); } else { Title = AppResources.NeverShare.ToLowerInvariant(); } BeginOnThreadPool(() => { _usersRule = StateService.UsersRule; StateService.UsersRule = null; if (_usersRule != null) { foreach (var userId in _usersRule.Users) { var user = CacheService.GetUser(userId); if (user != null) { Items.Add(user); } } Status = Items.Count > 0 || LazyItems.Count > 0 ? string.Empty : string.Format("{0}", AppResources.NoUsersHere); } }); }
private void CleanupUsers(IPrivacyValueUsersRule sourceList, IPrivacyValueUsersRule cleaningList) { var sourceDict = new Dictionary <int, int>(); foreach (var userId in sourceList.Users) { sourceDict[userId.Value] = userId.Value; } for (var i = 0; i < cleaningList.Users.Count; i++) { if (sourceDict.ContainsKey(cleaningList.Users[i].Value)) { cleaningList.Users.RemoveAt(i--); } } }