Skip to content

Commit

Permalink
Merge pull request #20251 from wordpress-mobile/issue/20250-deprecate…
Browse files Browse the repository at this point in the history
…-reblog-notification

🤖 Remove deprecated reblog notification type
  • Loading branch information
Antonis Lilis authored Feb 23, 2024
2 parents 1b9f91e + b0653b1 commit 228ea88
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 35 deletions.
5 changes: 1 addition & 4 deletions WordPress/src/main/java/org/wordpress/android/models/Note.kt
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ class Note {
get() = isTypeRaw(NOTE_LIKE_TYPE)
val isCommentLikeType: Boolean
get() = isTypeRaw(NOTE_COMMENT_LIKE_TYPE)
val isReblogType: Boolean
get() = isTypeRaw(NOTE_REBLOG_TYPE)
val isViewMilestoneType: Boolean
get() = isTypeRaw(NOTE_VIEW_MILESTONE)
val isCommentReplyType: Boolean
Expand All @@ -208,7 +206,7 @@ class Note {
// Returns true if the user has replied to this comment note
get() = isCommentType && !TextUtils.isEmpty(commentSubjectNoticon)
val isUserList: Boolean
get() = isLikeType || isFollowType || isReblogType
get() = isLikeType || isFollowType
val isUnread: Boolean // Parsing every time since it may change
get() = queryJSON("read", 0) != 1
val timestamp: Long
Expand Down Expand Up @@ -364,7 +362,6 @@ class Note {
const val NOTE_COMMENT_TYPE = "comment"
const val NOTE_MATCHER_TYPE = "automattcher"
const val NOTE_COMMENT_LIKE_TYPE = "comment_like"
const val NOTE_REBLOG_TYPE = "reblog"
const val NOTE_NEW_POST_TYPE = "new_post"
const val NOTE_VIEW_MILESTONE = "view_milestone"
const val NOTE_UNKNOWN_TYPE = "unknown"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
package org.wordpress.android.models

import org.wordpress.android.models.Notification.PostNotification.Like
import org.wordpress.android.models.Notification.PostNotification.Reblog
import org.wordpress.android.models.Notification.PostNotification.NewPost

val Note.type
get() = NoteType.from(rawType)

sealed class Notification {
sealed class PostNotification: Notification() {
abstract val url: String
abstract val title: String
data class Like(override val url: String, override val title: String): PostNotification()
data class Reblog(override val url: String, override val title: String): PostNotification()
data class NewPost(override val url: String, override val title: String): PostNotification()
}
data class PostLike(val url: String, val title: String): Notification()
data object NewPost: Notification()
data object Comment: Notification()
data object Unknown: Notification()

companion object {
fun from(rawNote: Note) = when(rawNote.type) {
NoteType.Like -> Like(url = rawNote.url, title = rawNote.title)
NoteType.Reblog -> Reblog(url= rawNote.url, title = rawNote.title)
NoteType.NewPost -> NewPost(url= rawNote.url, title = rawNote.title)
NoteType.PostLike -> PostLike(url = rawNote.url, title = rawNote.title)
NoteType.NewPost -> NewPost
NoteType.Comment -> Comment
else -> Unknown
}
}
}
enum class NoteType(val rawType: String) {
Follow(Note.NOTE_FOLLOW_TYPE),
Like(Note.NOTE_LIKE_TYPE),
PostLike(Note.NOTE_LIKE_TYPE),
Comment(Note.NOTE_COMMENT_TYPE),
Matcher(Note.NOTE_MATCHER_TYPE),
CommentLike(Note.NOTE_COMMENT_LIKE_TYPE),
Reblog(Note.NOTE_REBLOG_TYPE),
NewPost(Note.NOTE_NEW_POST_TYPE),
ViewMilestone(Note.NOTE_VIEW_MILESTONE),
Unknown(Note.NOTE_UNKNOWN_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public class GCMMessageHandler {
private static final String PUSH_TYPE_COMMENT_LIKE = "comment_like";
private static final String PUSH_TYPE_AUTOMATTCHER = "automattcher";
private static final String PUSH_TYPE_FOLLOW = "follow";
private static final String PUSH_TYPE_REBLOG = "reblog";
private static final String PUSH_TYPE_PUSH_AUTH = "push_auth";
private static final String PUSH_TYPE_BADGE_RESET = "badge-reset";
private static final String PUSH_TYPE_NOTE_DELETE = "note-delete";
Expand Down Expand Up @@ -749,8 +748,6 @@ private NotificationType fromNoteType(String noteType) {
return NotificationType.AUTOMATTCHER;
case PUSH_TYPE_FOLLOW:
return NotificationType.FOLLOW;
case PUSH_TYPE_REBLOG:
return NotificationType.REBLOG;
case PUSH_TYPE_PUSH_AUTH:
return NotificationType.AUTHENTICATION;
case PUSH_TYPE_BADGE_RESET:
Expand Down Expand Up @@ -1104,7 +1101,6 @@ private boolean shouldCircularizeNoteIcon(String noteType) {
case PUSH_TYPE_COMMENT_LIKE:
case PUSH_TYPE_AUTOMATTCHER:
case PUSH_TYPE_FOLLOW:
case PUSH_TYPE_REBLOG:
return true;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ enum class NotificationType {
COMMENT_LIKE,
AUTOMATTCHER,
FOLLOW,
REBLOG,
BADGE_RESET,
NOTE_DELETE,
TEST_NOTE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class NotificationsDetailListFragment : ListFragment(), NotificationFragment {
// Check if this is a comment notification that has been replied to
// The block will not have a type, and its id will match the comment reply id in the Note.
(blockObject.type == null && note.commentReplyId == commentReplyId)
} else if (note.isFollowType || note.isLikeType || note.isReblogType) {
} else if (note.isFollowType || note.isLikeType) {
// User list notifications have a footer if they have 10 or more users in the body
// The last block will not have a type, so we can use that to determine if it is the footer
blockObject.type == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.wordpress.android.fluxc.store.CommentsStore
import org.wordpress.android.fluxc.store.SiteStore
import org.wordpress.android.fluxc.utils.AppLogWrapper
import org.wordpress.android.models.Note
import org.wordpress.android.models.Notification.PostNotification
import org.wordpress.android.models.Notification.PostLike
import org.wordpress.android.modules.BG_THREAD
import org.wordpress.android.push.GCMMessageHandler
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalOverlayUtil
Expand Down Expand Up @@ -163,7 +163,7 @@ class NotificationsListViewModel @Inject constructor(
}

sealed class InlineActionEvent {
data class SharePostButtonTapped(val notification: PostNotification) : InlineActionEvent()
data class SharePostButtonTapped(val notification: PostLike) : InlineActionEvent()
class LikeCommentButtonTapped(val note: Note, val liked: Boolean) : InlineActionEvent()
class LikePostButtonTapped(val note: Note, val liked: Boolean) : InlineActionEvent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.wordpress.android.push.NotificationType.POST_PUBLISHED
import org.wordpress.android.push.NotificationType.POST_UPLOAD_ERROR
import org.wordpress.android.push.NotificationType.POST_UPLOAD_SUCCESS
import org.wordpress.android.push.NotificationType.QUICK_START_REMINDER
import org.wordpress.android.push.NotificationType.REBLOG
import org.wordpress.android.push.NotificationType.STORY_FRAME_SAVE_ERROR
import org.wordpress.android.push.NotificationType.STORY_FRAME_SAVE_SUCCESS
import org.wordpress.android.push.NotificationType.STORY_SAVE_ERROR
Expand Down Expand Up @@ -91,7 +90,6 @@ class SystemNotificationsTracker
COMMENT_LIKE -> COMMENT_LIKE_VALUE
AUTOMATTCHER -> AUTOMATTCHER_VALUE
FOLLOW -> FOLLOW_VALUE
REBLOG -> REBLOG_VALUE
BADGE_RESET -> BADGE_RESET_VALUE
NOTE_DELETE -> NOTE_DELETE_VALUE
TEST_NOTE -> TEST_NOTE_VALUE
Expand Down Expand Up @@ -127,7 +125,6 @@ class SystemNotificationsTracker
private const val COMMENT_LIKE_VALUE = "comment_like"
private const val AUTOMATTCHER_VALUE = "automattcher"
private const val FOLLOW_VALUE = "follow"
private const val REBLOG_VALUE = "reblog"
private const val BADGE_RESET_VALUE = "badge_reset"
private const val NOTE_DELETE_VALUE = "note_delete"
private const val TEST_NOTE_VALUE = "test_note"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ class NoteViewHolder(
fun bindInlineActions(note: Note) = Notification.from(note).let { notification ->
when (notification) {
Notification.Comment -> bindLikeCommentAction(note)
is Notification.PostNotification.NewPost -> bindLikePostAction(note)
is Notification.PostNotification -> bindShareAction(notification)
is Notification.NewPost -> bindLikePostAction(note)
is Notification.PostLike -> bindShareAction(notification)
is Notification.Unknown -> {
binding.action.isVisible = false
}
}
}

private fun bindShareAction(notification: Notification.PostNotification) {
private fun bindShareAction(notification: Notification.PostLike) {
binding.action.setImageResource(R.drawable.block_share)
val color = binding.root.context.getColorFromAttribute(R.attr.wpColorOnSurfaceMedium)
ImageViewCompat.setImageTintList(binding.action, ColorStateList.valueOf(color))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import org.wordpress.android.push.NotificationType.POST_PUBLISHED
import org.wordpress.android.push.NotificationType.POST_UPLOAD_ERROR
import org.wordpress.android.push.NotificationType.POST_UPLOAD_SUCCESS
import org.wordpress.android.push.NotificationType.QUICK_START_REMINDER
import org.wordpress.android.push.NotificationType.REBLOG
import org.wordpress.android.push.NotificationType.STORY_FRAME_SAVE_ERROR
import org.wordpress.android.push.NotificationType.STORY_FRAME_SAVE_SUCCESS
import org.wordpress.android.push.NotificationType.STORY_SAVE_ERROR
Expand Down Expand Up @@ -64,7 +63,6 @@ class SystemNotificationsTrackerTest {
COMMENT_LIKE to "comment_like",
AUTOMATTCHER to "automattcher",
FOLLOW to "follow",
REBLOG to "reblog",
BADGE_RESET to "badge_reset",
NOTE_DELETE to "note_delete",
TEST_NOTE to "test_note",
Expand Down

0 comments on commit 228ea88

Please sign in to comment.