public ConversationViewModel(ActivityGroupViewModel targetGroup, SelfStreamViewModel selfStream, CreateMessageViewModel replyMessage = null)
        {
            _selfStream = selfStream;
            CurrentGroup = targetGroup;
            if (replyMessage == null)
                IsEditing = false;
            else
            {
                IsEditing = true;
                Reply = replyMessage;
            }

            if (CurrentGroup == null)
            {
                CurrentGroup = new ActivityGroupViewModel("", false);
            }

            GotoReply = new RelayCommand(() =>
            {
                
                IsEditing = true;
				string targetUser = ActivityViewModel.GetAuthor(CurrentGroup.FirstActivity);
				if (targetUser == SnooStreamViewModel.RedditUserState.Username)
				{
					var betterActivity = ((IEnumerable<ActivityViewModel>)CurrentGroup.Activities).FirstOrDefault(vm => ActivityViewModel.GetAuthor(vm) != SnooStreamViewModel.RedditUserState.Username);
					if (betterActivity != null)
						targetUser = ActivityViewModel.GetAuthor(betterActivity);
				}
				Reply = new CreateMessageViewModel { Username = targetUser, Topic = CurrentGroup.FirstActivity.SubTitle, IsReply = true };
                RaisePropertyChanged("Reply");
                RaisePropertyChanged("IsEditing");
            });

            DeleteMessage = new RelayCommand(() =>
            {

            });

            GotoNewer = new RelayCommand(() =>
            {

            });

            GotoOlder = new RelayCommand(() =>
            {

            });
        }
        public static ViewModelBase LoadFromDump(string dump, ViewModelBase context, SnooStreamViewModel rootContext)
        {
            try
            {
                var stateItem = JsonConvert.DeserializeObject<Tuple<string, string>>(dump);
                switch (stateItem.Item1)
                {
                    case "AboutUserViewModel":
                        {
                            var accountThing = JsonConvert.DeserializeObject<Tuple<Account, DateTime>>(stateItem.Item2);
                            return new AboutUserViewModel(accountThing.Item1, accountThing.Item2);
                        }
                    case "AboutRedditViewModel":
                        {
                            var subredditThing = JsonConvert.DeserializeObject<Tuple<Subreddit, DateTime>>(stateItem.Item2);
                            return new AboutRedditViewModel(subredditThing.Item1, subredditThing.Item2);
                        }
                    case "LinkRiverViewModel":
                        {
                            Debug.Assert(context is SnooStreamViewModel);
                            var subredditThing = JsonConvert.DeserializeObject<Tuple<Subreddit, string, List<Link>, DateTime, string, string>>(stateItem.Item2);
                            var result = rootContext.SubredditRiver.GetOrMakeSubreddit(subredditThing.Item6, subredditThing.Item1, subredditThing.Item2, subredditThing.Item3, subredditThing.Item4);
                            result.CurrentSelected = result.Links.FirstOrDefault(lnk => lnk.Id == subredditThing.Item5);
                            return result;
                        }
                    case "CommentsViewModel":
                        {
                            var dumpArgs = JsonConvert.DeserializeObject<Tuple<Listing, string, string, DateTime?>>(stateItem.Item2);
                            LinkViewModel targetContext = null;
                            if (context is LinkRiverViewModel)
                                targetContext = ((LinkRiverViewModel)context).Links.FirstOrDefault(link => link.Id == dumpArgs.Item3) as LinkViewModel;

                            var comments = new CommentsViewModel(targetContext, dumpArgs.Item1, dumpArgs.Item2, dumpArgs.Item4);
                            if (targetContext != null)
                                targetContext.Comments = comments;

                            return comments;
                        }
                    case "SettingsViewModel":
                        {
                            return new SettingsViewModel(SnooStreamViewModel.Settings);
                        }
                    case "PostViewModel":
                        {
                            var dumpArgs = JsonConvert.DeserializeAnonymousType(stateItem.Item2, new { Editing = false, Kind = "", Subreddit = "", Text = "", Title = "", Url = "" });
                            return new PostViewModel()
                            {
                                Editing = dumpArgs.Editing,
                                Kind = dumpArgs.Kind,
                                Subreddit = dumpArgs.Subreddit,
                                Text = dumpArgs.Text,
                                Title = dumpArgs.Title,
                                Url = dumpArgs.Url,
                            };
                        }
                    case "MessageViewModel":
                        {
                            var postViewModel = new CreateMessageViewModel();
                            return postViewModel;
                        }
                    case "ConversationViewModel":
                        {
                            var dumpArgs = JsonConvert.DeserializeAnonymousType(stateItem.Item2, new { ActivityId = "", Username = "", Topic = "", Contents = "", IsReply = false });
                            CreateMessageViewModel createMessage = null;
                            if (!string.IsNullOrWhiteSpace(dumpArgs.Username) || !string.IsNullOrWhiteSpace(dumpArgs.Topic) || !string.IsNullOrWhiteSpace(dumpArgs.Contents))
                            {
                                createMessage = new CreateMessageViewModel { Contents = dumpArgs.Contents, Topic = dumpArgs.Topic, Username = dumpArgs.Username, IsReply = dumpArgs.IsReply };
                            }

                            ActivityGroupViewModel targetGroup;
                            if (!string.IsNullOrWhiteSpace(dumpArgs.ActivityId) && rootContext.SelfStream.Groups.TryGetValue(dumpArgs.ActivityId, out targetGroup))
                            {
                                return new ConversationViewModel(targetGroup, rootContext.SelfStream, createMessage);
                            }
                            else
                            {
                                return new ConversationViewModel(null, rootContext.SelfStream, createMessage);
                            }
                        }
                    case "CommentsContentStreamViewModel":
                        {
                            var dumpArgs = JsonConvert.DeserializeObject<Tuple<string, string>>(stateItem.Item2);
                            Debug.Assert(context is CommentsViewModel);
                            var commentsViewModel = context as CommentsViewModel;
                            var streamViewModel = new CommentsContentStreamViewModel(commentsViewModel);
                            streamViewModel.CurrentSelected = streamViewModel.Links.FirstOrDefault(linkVM => linkVM.Id == dumpArgs.Item1 && linkVM.Url == dumpArgs.Item2);
                            return streamViewModel;
                        }
                    case "LoginViewModel":
                        {
                            return rootContext.Login;
                        }
                    default:
                        throw new InvalidOperationException(stateItem.Item1);
                }
            }
            catch (Exception ex)
            {
                ////_logger.Fatal(string.Format("dump was {0}", dump), ex);
                throw;
            }
        }