Example #1
0
        private void AddComment(Commentable post)
        {
            if (post == null)
            {
                if (SelectedPost == null)
                {
                    return;
                }
                else
                {
                    post = SelectedPost as Commentable;
                }
            }

            var dlg = EditPostWindow.CreateForComment(api, post);

            dlg.Owner = window;

            dlg.ShowDialog();

            if (!dlg.Cancelled)
            {
                post.IncrementComments();
            }
        }
Example #2
0
        internal static async Task <bool> HandleButtons(Window window, ButtonClickedEventArgs args)
        {
            EditPostWindow editPost;

            switch (args.Type)
            {
            case ButtonType.Up:
            case ButtonType.Down:
                await Utilities.Vote(args);

                break;

            case ButtonType.Reply:
                if (args.SelectedItem is Commentable)
                {
                    Commentable ctbl = args.SelectedItem as Commentable;
                    editPost       = EditPostWindow.CreateForComment(AppManager.Instance.API, ctbl);
                    editPost.Owner = window;
                    editPost.ShowDialog();

                    if (!editPost.Cancelled)
                    {
                        ctbl.IncrementComments();
                    }
                }
                break;

            case ButtonType.Delete:
                switch (args.SelectedItem.Type)
                {
                case FeedItem.FeedItemType.Post:
                    AppManager.Instance.API.User.DeleteRant(args.SelectedItem.AsRant().ID);
                    break;

                case FeedItem.FeedItemType.Comment:
                    AppManager.Instance.API.User.DeleteComment(args.SelectedItem.AsComment().ID);
                    break;
                }
                break;

            case ButtonType.Edit:
                TimeSpan timespan = DateTime.Now.ToUniversalTime() - FromUnixTime(args.SelectedItem.RawCreateTime);
                if (timespan > MaxModifyMinutes)
                {
                    throw new Exception(args.SelectedItem.Type + " can no longer be edited.");
                }

                editPost       = EditPostWindow.CreateForEdit(AppManager.Instance.API, args.SelectedItem);
                editPost.Owner = window;
                editPost.ShowDialog();
                break;
            }

            return(true);
        }
Example #3
0
        private void MakePost()
        {
            var dlg = EditPostWindow.CreateForRant();

            dlg.Owner = window;

            dlg.ShowDialog();

            if (!dlg.Cancelled)
            {
                if (dlg.AddedDraft != null)
                {
                    //TODO: Should store the added draft in mem?
                    UpdateDrafts(db.GetNumberOfDrafts());
                }
            }
        }
Example #4
0
        public async void OpenPost()
        {
            if (SelectedPost == null)
            {
                return;
            }
            else if (await Utilities.OpenFeedItem(SelectedPost, api, window))
            {
                if (SelectedPost is ViewModels.Notification)
                {
                    ViewModels.Notification notif = SelectedPost as ViewModels.Notification;
                    foreach (ViewModels.Notification n in feeds)
                    {
                        if (n.RantId == notif.RantId)
                        {
                            n.MarkRead();
                        }
                    }

                    UpdateNotifications(new NotificationsChecker.UpdateArgs(feeds.Where(x => !x.Read).Count(), feeds.Count));
                    FeedView.Refresh();
                }
            }
            else if (SelectedPost is Draft)
            {
                var dlg = EditPostWindow.CreateForRant(SelectedPost as Draft);
                dlg.Owner = window;

                dlg.ShowDialog();

                if (!dlg.Cancelled)
                {
                    UpdateDrafts(AppManager.Instance.DB.GetNumberOfDrafts());
                    LoadDrafts();
                }
            }
        }
        public static EditPostWindow CreateForEdit(IDevRantClient api, FeedItem existing)
        {
            var window = new EditPostWindow(existing);

            return(window);
        }
        public static EditPostWindow CreateForComment(IDevRantClient api, Commentable parent)
        {
            var window = new EditPostWindow(Type.Comment, parent: parent);

            return(window);
        }
        public static EditPostWindow CreateForRant(Draft existing = null)
        {
            var window = new EditPostWindow(Type.Rant, existing);

            return(window);
        }