|
36 | 36 | import org.wordpress.android.fluxc.store.SiteStore; |
37 | 37 | import org.wordpress.android.models.Note; |
38 | 38 | import org.wordpress.android.ui.comments.unified.CommentsStoreAdapter; |
39 | | -import org.wordpress.android.ui.main.WPMainActivity; |
40 | | -import org.wordpress.android.ui.notifications.NotificationsListFragment; |
41 | 39 | import org.wordpress.android.ui.notifications.SystemNotificationsTracker; |
42 | 40 | import org.wordpress.android.ui.notifications.receivers.NotificationsPendingDraftsReceiver; |
43 | 41 | import org.wordpress.android.ui.notifications.utils.NotificationsActions; |
@@ -612,49 +610,31 @@ private void replyToComment() { |
612 | 610 | return; |
613 | 611 | } |
614 | 612 |
|
615 | | - if (!TextUtils.isEmpty(mReplyText)) { |
616 | | - SiteModel site = mSiteStore.getSiteBySiteId(mNote.getSiteId()); |
617 | | - if (site == null) { |
618 | | - AppLog.e(T.NOTIFS, "Impossible to reply to a comment on a site that is not in the App." |
619 | | - + " SiteId: " + mNote.getSiteId()); |
620 | | - requestFailed(ARG_ACTION_APPROVE); |
621 | | - return; |
622 | | - } |
| 613 | + if (TextUtils.isEmpty(mReplyText)) return; |
623 | 614 |
|
624 | | - // Pseudo comment (built from the note) |
625 | | - CommentModel comment = mNote.buildComment(); |
| 615 | + SiteModel site = mSiteStore.getSiteBySiteId(mNote.getSiteId()); |
| 616 | + if (site == null) { |
| 617 | + AppLog.e(T.NOTIFS, "Impossible to reply to a comment on a site that is not in the App." |
| 618 | + + " SiteId: " + mNote.getSiteId()); |
| 619 | + requestFailed(ARG_ACTION_APPROVE); |
| 620 | + return; |
| 621 | + } |
626 | 622 |
|
627 | | - // Pseudo comment reply |
628 | | - CommentModel reply = new CommentModel(); |
629 | | - reply.setContent(mReplyText); |
| 623 | + // Pseudo comment (built from the note) |
| 624 | + CommentModel comment = mNote.buildComment(); |
630 | 625 |
|
631 | | - // Push the reply |
632 | | - RemoteCreateCommentPayload payload = new RemoteCreateCommentPayload(site, comment, reply); |
633 | | - mCommentsStoreAdapter.dispatch(CommentActionBuilder.newCreateNewCommentAction(payload)); |
| 626 | + // Pseudo comment reply |
| 627 | + CommentModel reply = new CommentModel(); |
| 628 | + reply.setContent(mReplyText); |
634 | 629 |
|
635 | | - // Bump analytics |
636 | | - AnalyticsUtils.trackCommentReplyWithDetails(true, |
637 | | - site, comment, AnalyticsCommentActionSource.NOTIFICATIONS); |
638 | | - AnalyticsUtils.trackQuickActionTouched(QuickActionTrackPropertyValue.REPLY_TO, site, comment); |
639 | | - } else { |
640 | | - // cancel the current notification |
641 | | - NativeNotificationsUtils.dismissNotification(mPushId, mContext); |
642 | | - NativeNotificationsUtils.hideStatusBar(mContext); |
643 | | - // and just trigger the Activity to allow the user to write a reply |
644 | | - startReplyToCommentActivity(); |
645 | | - } |
646 | | - } |
| 630 | + // Push the reply |
| 631 | + RemoteCreateCommentPayload payload = new RemoteCreateCommentPayload(site, comment, reply); |
| 632 | + mCommentsStoreAdapter.dispatch(CommentActionBuilder.newCreateNewCommentAction(payload)); |
647 | 633 |
|
648 | | - private void startReplyToCommentActivity() { |
649 | | - Intent intent = new Intent(mContext, WPMainActivity.class); |
650 | | - intent.putExtra(WPMainActivity.ARG_OPENED_FROM_PUSH, true); |
651 | | - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK |
652 | | - | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
653 | | - intent.setAction("android.intent.action.MAIN"); |
654 | | - intent.addCategory("android.intent.category.LAUNCHER"); |
655 | | - intent.putExtra(NotificationsListFragment.NOTE_ID_EXTRA, mNoteId); |
656 | | - intent.putExtra(NotificationsListFragment.NOTE_INSTANT_REPLY_EXTRA, true); |
657 | | - startActivity(intent); |
| 634 | + // Bump analytics |
| 635 | + AnalyticsUtils.trackCommentReplyWithDetails(true, |
| 636 | + site, comment, AnalyticsCommentActionSource.NOTIFICATIONS); |
| 637 | + AnalyticsUtils.trackQuickActionTouched(QuickActionTrackPropertyValue.REPLY_TO, site, comment); |
658 | 638 | } |
659 | 639 |
|
660 | 640 | private void resetOriginalNotification() { |
|
0 commit comments