copy text and fix notifications for DM

This commit is contained in:
callebtc
2025-07-13 23:42:58 +02:00
parent 2b63c7805e
commit 20cf8b59f8
3 changed files with 22 additions and 21 deletions
@@ -49,7 +49,6 @@ class MeshDelegateHandler(
// Show notification with enhanced information - now includes senderPeerID // Show notification with enhanced information - now includes senderPeerID
message.senderPeerID?.let { senderPeerID -> message.senderPeerID?.let { senderPeerID ->
if (state.getSelectedPrivateChatPeerValue() != senderPeerID) {
// Use nickname if available, fall back to sender or senderPeerID // Use nickname if available, fall back to sender or senderPeerID
val senderNickname = message.sender.takeIf { it != senderPeerID } ?: senderPeerID val senderNickname = message.sender.takeIf { it != senderPeerID } ?: senderPeerID
notificationManager.showPrivateMessageNotification( notificationManager.showPrivateMessageNotification(
@@ -58,7 +57,6 @@ class MeshDelegateHandler(
messageContent = message.content messageContent = message.content
) )
} }
}
} else if (message.channel != null) { } else if (message.channel != null) {
// Channel message // Channel message
if (state.getJoinedChannelsValue().contains(message.channel)) { if (state.getJoinedChannelsValue().contains(message.channel)) {
@@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.* import androidx.compose.material3.*
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@@ -41,6 +42,7 @@ fun MessagesList(
} }
} }
SelectionContainer {
LazyColumn( LazyColumn(
state = listState, state = listState,
modifier = modifier.padding(horizontal = 12.dp, vertical = 8.dp), modifier = modifier.padding(horizontal = 12.dp, vertical = 8.dp),
@@ -54,6 +56,7 @@ fun MessagesList(
) )
} }
} }
}
} }
@Composable @Composable
@@ -96,7 +96,7 @@ class NotificationManager(private val context: Context) {
*/ */
fun showPrivateMessageNotification(senderPeerID: String, senderNickname: String, messageContent: String) { fun showPrivateMessageNotification(senderPeerID: String, senderNickname: String, messageContent: String) {
// Only show notifications if app is in background OR user is not viewing this specific chat // Only show notifications if app is in background OR user is not viewing this specific chat
val shouldNotify = isAppInBackground || currentPrivateChatPeer != senderPeerID val shouldNotify = isAppInBackground || (!isAppInBackground && currentPrivateChatPeer != senderPeerID)
if (!shouldNotify) { if (!shouldNotify) {
Log.d(TAG, "Skipping notification - app in foreground and viewing chat with $senderNickname") Log.d(TAG, "Skipping notification - app in foreground and viewing chat with $senderNickname")