예제 #1
0
        /// <summary>
        /// Called when the send button is tapped.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Send_OnIconTapped(object sender, EventArgs e)
        {
            string comment = ui_textBox.Text;

            if (String.IsNullOrWhiteSpace(comment))
            {
                App.BaconMan.MessageMan.ShowMessageSimple("\"Silence is a source of great strength.\" - Lao Tzu", "Except on reddit. Go on, say something.");
                return;
            }

            // Show loading
            ui_sendingOverlayProgress.IsActive = true;
            VisualStateManager.GoToState(this, "ShowOverlay", true);

            // Try to send the comment
            string response = await Task.Run(() => MiscellaneousHelper.SendRedditComment(App.BaconMan, m_itemRedditId, comment));

            // If we have a post send the status to the collector
            bool wasSuccess = false;

            if (m_parentPost != null)
            {
                // Get the comment collector for this post.
                CommentCollector collector = CommentCollector.GetCollector(m_parentPost, App.BaconMan);

                // Tell the collector of the change, this will show any message boxes needed.
                wasSuccess = await Task.Run(() => collector.AddNewUserComment(response, m_itemRedditId));
            }
            else
            {
                // If we are here we are a message. Validate for ourselves.
                // #todo, make this validation better, add capta support. Both responses to messages and post replies will have "author"
                if (!String.IsNullOrWhiteSpace(response) && response.Contains("author"))
                {
                    wasSuccess = true;
                }
                else
                {
                    wasSuccess = false;
                    App.BaconMan.MessageMan.ShowMessageSimple("That's Not Right", "We can't send this message right now, check your Internet connection");
                }
            }


            if (wasSuccess)
            {
                // Clear the reddit id so we won't open back up with the
                // same text
                m_itemRedditId = "";

                // Hide the comment box.
                HideBox();
            }
            else
            {
                // Hide the overlay
                VisualStateManager.GoToState(this, "HideOverlay", true);
            }
        }
예제 #2
0
        /// <summary>
        /// Called when the send button is tapped.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Send_Click(object sender, RoutedEventArgs e)
        {
            // Make sure we have a string unless we are editing a post selftext, then we can have an empty comment.
            string comment = ui_textBox.Text;

            if (String.IsNullOrWhiteSpace(comment) && !m_itemRedditId.StartsWith("t3_") && !m_isEdit)
            {
                App.BaconMan.MessageMan.ShowMessageSimple("\"Silence is a source of great strength.\" - Lao Tzu", "Except on reddit. Go on, say something.");
                return;
            }

            // Show loading
            ui_sendingOverlayProgress.IsActive = true;
            VisualStateManager.GoToState(this, "ShowOverlay", true);

            // Try to send the comment
            string response = await Task.Run(() => MiscellaneousHelper.SendRedditComment(App.BaconMan, m_itemRedditId, comment, m_isEdit));

            if (response != null)
            {
                // Now fire the event that a comment was submitted.
                try
                {
                    OnCommentSubmittedArgs args = new OnCommentSubmittedArgs()
                    {
                        Response = response,
                        IsEdit   = m_isEdit,
                        RedditId = m_itemRedditId,
                        Context  = m_context,
                    };
                    m_onCommentSubmitted.Raise(this, args);
                }
                catch (Exception ex)
                {
                    App.BaconMan.MessageMan.DebugDia("failed to fire OnCommentSubmitted", ex);
                    App.BaconMan.TelemetryMan.ReportUnexpectedEvent(this, "OnCommentSubmittedFireFailed", ex);
                }
            }
            else
            {
                // The network call failed.
                App.BaconMan.MessageMan.ShowMessageSimple("Can't Submit", "We can't seem to submit this right now, check your internet connection.");
                HideLoadingOverlay();
            }
        }