public SelectTwitterListViewModel(Decimal TwitterAccountID, MetroTwitUser userToAdd) { SelectTwitterListViewModel twitterListViewModel = this; this.UserToAdd = userToAdd; this.TwitterAccountID = TwitterAccountID; this.TwitterLists = new ObservableCollection<TwitterListExtended>(); this.FailedLists = new ObservableCollection<Tuple<IEnumerable<TwitterError>, TwitterList>>(); this.SaveCommand = new RelayCommand(new Action(this.Save)); this.CancelCommand = new RelayCommand(new Action(this.Cancel)); this.ProgressText = "Loadings lists..."; this.showAnimation = true; this.showLists = false; this.showFailedLists = false; this.countLock = new object(); App.GetLists(this.TwitterAccountID, (Action<TwitterListCollection>)(listsCollection => { if (listsCollection == null || listsCollection.Count <= 0) return; MetroTwitTwitterizer.ListMembershipsOptions.FilterToOwnedLists = true; Lists.MembershipsAsync(App.AppState.Accounts[twitterListViewModel.TwitterAccountID].Tokens, userToAdd.ScreenName, MetroTwitTwitterizer.ListMembershipsOptions).ContinueWith((Action<Task<TwitterResponse<TwitterListCollection>>>)(response => { if (response.Result.Result == RequestResult.Success) { TwitterListCollection memberships = response.Result.ResponseObject; foreach (TwitterList item_0 in (Collection<TwitterList>)listsCollection) { TwitterList item = item_0; System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { bool local_0 = Enumerable.FirstOrDefault<TwitterList>(Enumerable.Where<TwitterList>((IEnumerable<TwitterList>)memberships, (Func<TwitterList, bool>)(tl => tl.Id == item.Id))) != null; ObservableCollection<TwitterListExtended> temp_155 = twitterListViewModel.TwitterLists; TwitterListExtended temp_171 = new TwitterListExtended() { TwitterAccountID = twitterListViewModel.TwitterAccountID, IsEditable = true, BaseListObject = item, IsSelected = local_0, AlreadyExistsInMembership = local_0 }; temp_155.Add(temp_171); })); } twitterListViewModel.ShowAnimation = false; twitterListViewModel.ShowLists = true; twitterListViewModel.ShowFailedLists = false; } else twitterListViewModel.ShowAnimation = false; })); })); }
internal void AddFollowedUser(MetroTwitUser User) { if (User == null) return; string key = this.CacheUserName(User.ScreenName); if (!this.CachedUsers.ContainsKey(key)) { this.CachedUsers.Add(key, new CacheUser() { TwitterID = User.Id, ScreenName = User.ScreenName, FullName = User.Name, ImageURITwitterSecure = User.ProfileImageSecureLocation, Expiry = DateTime.Now.AddHours(6.0), ImageURILocal = this.UserImageURI(User.ProfileImageLocation, User.ScreenName) }); if (this.NonCachedUsers.ContainsKey(key)) this.NonCachedUsers.Remove(key); } }
internal async static Task<bool?> Follow(string AdUrl, MetroTwitUser User, decimal TwitterAccountID, string FollowText = "following...") { bool? nullable; try { IEnumerable<TwitterError> errors; if (FollowText == "following...") { TwitterResponse<User> response = await Friendship.CreateAsync(App.AppState.Accounts[TwitterAccountID].Tokens, User.ScreenName, MetroTwitTwitterizer.CreateFriendshipOptions); TwitterResponse<User> r = response; if (r.Result == RequestResult.Success) { App.AppState.Accounts[TwitterAccountID].Cache.AddFollowedUser(User); App.AppState.Accounts[TwitterAccountID].Cache.RemoveBlockedUser((long)User.Id); nullable = true; } else { nullable = false; } return nullable; } if (FollowText == "it's you") { Messenger.Default.Send<DialogMessage>(new DialogMessage(string.Empty, delegate(MessageBoxResult o) { }), DialogType.FollowSelf); return null; } bool _answer = false; Messenger.Default.Send<DialogMessage>(new DialogMessage(User.ScreenName, delegate(MessageBoxResult answer) { _answer = answer == MessageBoxResult.Yes; }), DialogType.DeleteFriendship); if (_answer) { TwitterResponse<User> r = await Friendship.DeleteAsync(App.AppState.Accounts[TwitterAccountID].Tokens, User.Id, User.ScreenName, MetroTwitTwitterizer.Options); if (r.Result == RequestResult.Success) { App.AppState.Accounts[TwitterAccountID].Cache.RemovedFollowedUser(User); nullable = true; } else { nullable = false; } } else { nullable = false; } } catch { nullable = false; } return nullable; }
internal void RemovedFollowedUser(MetroTwitUser User) { if (User == null || !this.CachedUsers.ContainsKey(this.CacheUserName(User.ScreenName))) return; this.CachedUsers.Remove(this.CacheUserName(User.ScreenName)); }