public RelationControlViewModel(UserInfoViewModel parent, AuthenticateInfo source, TwitterUser target)
 {
     this._parent = parent;
     this._source = source;
     this._target = target;
     var rds = source.GetRelationData();
     this.IsFollowing = rds.IsFollowing(target.Id);
     this.IsFollowedBack = rds.IsFollowedBy(target.Id);
     this.IsBlocking = rds.IsBlocking(target.Id);
     source.GetFriendship(source.Id, target_id: target.Id)
           .Subscribe(
               r =>
               {
                   // ReSharper disable InvertIf
                   if (this.IsFollowing != r.relationship.source.following)
                   {
                       this.IsFollowing = r.relationship.source.following;
                       if (r.relationship.source.following)
                       {
                           rds.AddFollowing(target.Id);
                       }
                       else
                       {
                           rds.RemoveFollowing(target.Id);
                       }
                   }
                   if (this.IsFollowedBack != r.relationship.source.followed_by)
                   {
                       this.IsFollowedBack = r.relationship.source.followed_by;
                       if (r.relationship.source.followed_by)
                       {
                           rds.AddFollower(target.Id);
                       }
                       else
                       {
                           rds.RemoveFollower(target.Id);
                       }
                   }
                   if (this.IsBlocking != r.relationship.source.blocking)
                   {
                       this.IsBlocking = r.relationship.source.blocking;
                       if (r.relationship.source.blocking)
                       {
                           rds.AddBlocking(target.Id);
                       }
                       else
                       {
                           rds.RemoveBlocking(target.Id);
                       }
                   }
                   // ReSharper restore InvertIf
               },
               ex =>
               {
                   this.Enabled = false;
               });
 }
Example #2
0
 public BackstageAccountModel(AuthenticateInfo info)
 {
     this._info = info;
     this.UpdateConnectionState();
     StoreHelper.GetUser(_info.Id)
                .Subscribe(
                    u =>
                    {
                        _user = u;
                        this.OnTwitterUserChanged();
                    },
                    ex => BackstageModel.RegisterEvent(
                        new OperationFailedEvent("Could not receive user info: " +
                                                 this._info.UnreliableScreenName +
                                                 " - " + ex.Message)));
 }
Example #3
0
 public static void NotifyRetweeted(TwitterUser source, TwitterStatus status)
 {
     Action<TwitterStatusEvent> handler = OnRetweeted;
     if (handler != null)
         handler(new TwitterStatusEvent(source, status));
 }
Example #4
0
 public static void NotifyFollowed(TwitterUser source, TwitterUser target)
 {
     var handler = Followed;
     if (handler != null)
         handler(new TwitterUserEvent(source, target));
 }
Example #5
0
 public static void Store(TwitterUser user)
 {
     if (_isInShutdown) return;
     _dispatcher.Send(user);
     lock (_snResolverLocker)
     {
         _screenNameResolver[user.ScreenName.ToLower()] = user.Id;
     }
 }
Example #6
0
 public void Deserialize(System.IO.BinaryReader reader)
 {
     Id = reader.ReadInt64();
     StatusType = (StatusType)reader.ReadInt32();
     User = reader.ReadObject<TwitterUser>();
     Text = reader.ReadString();
     CreatedAt = reader.ReadDateTime();
     IsFavored = reader.ReadBoolean();
     if (reader.ReadBoolean())
     {
         Source = reader.ReadString();
     }
     InReplyToStatusId = reader.ReadNullableLong();
     InReplyToUserId = reader.ReadNullableLong();
     if (reader.ReadBoolean())
     {
         InReplyToScreenName = reader.ReadString();
     }
     RetweetedOriginalId = reader.ReadNullableLong();
     Latitude = reader.ReadNullableDouble();
     Longitude = reader.ReadNullableDouble();
     if (reader.ReadBoolean())
     {
         FavoritedUsers = reader.ReadIds().ToArray();
     }
     if (reader.ReadBoolean())
     {
         RetweetedUsers = reader.ReadIds().ToArray();
     }
     RetweetedOriginal = reader.ReadObject<TwitterStatus>();
     Recipient = reader.ReadObject<TwitterUser>();
     if (reader.ReadBoolean())
     {
         Entities = reader.ReadCollection<TwitterEntity>().ToArray();
     }
 }
Example #7
0
 public TwitterEventBase(TwitterUser source, TwitterUser target)
 {
     this._createdAt = DateTime.Now;
     this._source = source;
     this._targetUser = target;
 }
Example #8
0
 public RetweetedEvent(TwitterUser source, TwitterStatus target)
     : base(source, target)
 {
 }
Example #9
0
 public UserViewModel(TwitterUser user)
 {
     Model = UserModel.Get(user);
 }
Example #10
0
 public static UserModel Get(TwitterUser user)
 {
     return new UserModel(user);
 }
Example #11
0
 public UnfavoritedEvent(TwitterUser user, TwitterStatus target)
     : base(user, target)
 {
 }
Example #12
0
 public UserResultItemViewModel(TwitterUser user)
     : base(user)
 {
 }
Example #13
0
        public void AddFavoritedUser(TwitterUser user)
        {
            if (this.Status.RetweetedOriginal != null)
            {
                Get(this.Status.RetweetedOriginal)
                    .AddFavoritedUser(user);
            }
            else
            {

                bool added = false;
                lock (_favoritedsLock)
                {
                    if (!_favoritedUsersDic.ContainsKey(user.Id))
                    {
                        _favoritedUsersDic.Add(user.Id, user);
                        Status.FavoritedUsers = Status.FavoritedUsers.Guard()
                                                      .Append(user.Id)
                                                      .Distinct()
                                                      .ToArray();
                        added = true;
                    }
                }
                if (added)
                {
                    _favoritedUsers.Add(user);
                    StatusStore.Store(Status);
                }
            }
        }
Example #14
0
 public static void ShowUserInfo(TwitterUser user)
 {
 }
Example #15
0
 public static void SetTwitterUser(DependencyObject obj, TwitterUser value)
 {
     obj.SetValue(TwitterUserProperty, value);
 }
Example #16
0
 public static void NotifyUnblocked(TwitterUser source, TwitterUser target)
 {
     Action<TwitterUserEvent> handler = OnUnblocked;
     if (handler != null)
         handler(new TwitterUserEvent(source, target));
 }
Example #17
0
 public UnfollowedEvent(TwitterUser source, TwitterUser target)
     : base(source, target)
 {
 }
Example #18
0
 private UserModel(TwitterUser user)
 {
     User = user;
 }
Example #19
0
 public async void AddRetweetedUser(TwitterUser user)
 {
     if (this.Status.RetweetedOriginal != null)
     {
         var status = await Get(this.Status.RetweetedOriginal);
         status.AddRetweetedUser(user);
     }
     else
     {
         var added = false;
         lock (_retweetedsLock)
         {
             if (!_retweetedUsersDic.ContainsKey(user.Id))
             {
                 _retweetedUsersDic.Add(user.Id, user);
                 Status.RetweetedUsers = Status.RetweetedUsers.Guard()
                                               .Append(user.Id)
                                               .Distinct()
                                               .ToArray();
                 added = true;
             }
         }
         if (added)
         {
             _retweetedUsers.Add(user);
             // update persistent info
             StatusStore.Store(Status);
         }
     }
 }
Example #20
0
 public static void SetDirectMessage(IEnumerable<AuthenticateInfo> info, TwitterUser recipient,
                                     bool focusToInputArea = true)
 {
     Action<IEnumerable<AuthenticateInfo>, TwitterUser> handler = OnSendDirectMessageRequested;
     if (handler != null)
         handler(info, recipient);
     if (focusToInputArea)
         MainWindowModel.SetFocusTo(FocusRequest.Tweet);
 }
Example #21
0
 public static void Store(TwitterUser user)
 {
     if (_isInShutdown) return;
     Task.Run(() => _store.Store(user));
     lock (SnResolverLocker)
     {
         ScreenNameResolver[user.ScreenName] = user.Id;
     }
 }
Example #22
0
 public TwitterStatusEvent(TwitterUser source, TwitterStatus target)
 {
     Source = source;
     Target = target;
 }
Example #23
0
 public TwitterEventBase(TwitterUser source, TwitterStatus target)
     : this(source, target.User)
 {
     this._targetStatus = target;
 }
Example #24
0
 public TwitterUserEvent(TwitterUser source, TwitterUser target)
 {
     Source = source;
     Target = target;
 }
Example #25
0
 public FavoritedEvent(TwitterUser source, TwitterStatus target)
     : base(source, target)
 {
 }
Example #26
0
 public static void NotifyFavorited(TwitterUser source, TwitterStatus target)
 {
     Action<TwitterStatusEvent> handler = OnFavorited;
     if (handler != null)
         handler(new TwitterStatusEvent(source, target));
 }
Example #27
0
 public BlockedEvent(TwitterUser source, TwitterUser target)
     : base(source, target)
 {
 }
Example #28
0
 public static void NotifyUnfavorited(TwitterUser source, TwitterStatus status)
 {
     var handler = Unfavorited;
     if (handler != null)
         handler(new TwitterStatusEvent(source, status));
 }