diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/MessageTable.kt b/app/src/main/java/org/thoughtcrime/securesms/database/MessageTable.kt index e45e56e047..3a92dee3a5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/MessageTable.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/MessageTable.kt @@ -2232,7 +2232,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat NOTIFIED to 1, REACTIONS_LAST_SEEN to System.currentTimeMillis() ) - .where("$ID = ?", id) + .where("$ID = ? OR $ORIGINAL_MESSAGE_ID = ? OR $LATEST_REVISION_ID = ?", id, id, id) .run() } @@ -2710,6 +2710,17 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat contentValues.put(QUOTE_AUTHOR, 0) } + if (editedMessage != null) { + val notified = readableDatabase + .select(NOTIFIED) + .from(TABLE_NAME) + .where(ID_WHERE, editedMessage.id) + .run() + .readToSingleInt(0) + + contentValues.put(NOTIFIED, notified.toInt()) + } + val (messageId, insertedAttachments) = insertMediaMessage( threadId = threadId, body = retrieved.body, @@ -4876,7 +4887,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat AND $STORY_TYPE = 0 AND $LATEST_REVISION_ID IS NULL AND ( - $READ = 0 + ($READ = 0 AND ($ORIGINAL_MESSAGE_ID IS NULL OR EXISTS (SELECT 1 FROM $TABLE_NAME AS m WHERE m.$ID = $TABLE_NAME.$ORIGINAL_MESSAGE_ID AND m.$READ = 0))) OR $REACTIONS_UNREAD = 1 ${if (stickyQuery.isNotEmpty()) "OR ($stickyQuery)" else ""} OR ($IS_MISSED_CALL_TYPE_CLAUSE AND EXISTS (SELECT 1 FROM ${CallTable.TABLE_NAME} WHERE ${CallTable.MESSAGE_ID} = $TABLE_NAME.$ID AND ${CallTable.EVENT} = ${CallTable.Event.serialize(CallTable.Event.MISSED)} AND ${CallTable.READ} = 0)) diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/v2/NotificationFactory.kt b/app/src/main/java/org/thoughtcrime/securesms/notifications/v2/NotificationFactory.kt index bbb013d370..9e1766c75a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/v2/NotificationFactory.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/v2/NotificationFactory.kt @@ -160,9 +160,11 @@ object NotificationFactory { val threadsThatNewlyAlerted: MutableSet = mutableSetOf() state.conversations.forEach { conversation -> - if (conversation.thread == visibleThread && conversation.hasNewNotifications()) { - Log.internal().i(TAG, "Thread is visible, notifying in thread. notificationId: ${conversation.notificationId}") - notifyInThread(context, conversation.recipient, lastAudibleNotification) + if (conversation.thread == visibleThread) { + if (conversation.hasNewNotifications()) { + Log.internal().i(TAG, "Thread is visible, notifying in thread. notificationId: ${conversation.notificationId}") + notifyInThread(context, conversation.recipient, lastAudibleNotification) + } } else if (notificationConfigurationChanged || conversation.hasNewNotifications() || alertOverrides.contains(conversation.thread) || !conversation.hasSameContent(previousState.getConversation(conversation.thread))) { if (conversation.hasNewNotifications()) { threadsThatNewlyAlerted += conversation.thread