feat: Integrate ChatsListViewModel for user block/unblock functionality in OtherProfileScreen
This commit is contained in:
@@ -244,14 +244,10 @@ fun ChatDetailScreen(
|
||||
var showBlockConfirm by remember { mutableStateOf(false) }
|
||||
var showUnblockConfirm by remember { mutableStateOf(false) }
|
||||
|
||||
// Проверяем, заблокирован ли пользователь (отложенно, не блокирует UI)
|
||||
var isBlocked by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(user.publicKey, currentUserPublicKey) {
|
||||
// 🔥 ОПТИМИЗАЦИЯ: Отложенная проверка - не блокирует анимацию
|
||||
kotlinx.coroutines.delay(100) // Даём анимации завершиться
|
||||
isBlocked =
|
||||
database.blacklistDao().isUserBlocked(user.publicKey, currentUserPublicKey)
|
||||
}
|
||||
// Наблюдаем за статусом блокировки в реальном времени через Flow
|
||||
val isBlocked by database.blacklistDao()
|
||||
.observeUserBlocked(user.publicKey, currentUserPublicKey)
|
||||
.collectAsState(initial = false)
|
||||
|
||||
// Подключаем к ViewModel
|
||||
val messages by viewModel.messages.collectAsState()
|
||||
@@ -1901,7 +1897,6 @@ fun ChatDetailScreen(
|
||||
currentUserPublicKey
|
||||
)
|
||||
)
|
||||
isBlocked = true
|
||||
} catch (e: Exception) {
|
||||
// Error blocking user
|
||||
}
|
||||
@@ -1948,7 +1943,6 @@ fun ChatDetailScreen(
|
||||
account =
|
||||
currentUserPublicKey
|
||||
)
|
||||
isBlocked = false
|
||||
} catch (e: Exception) {
|
||||
// Error unblocking user
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.rosetta.messenger.crypto.CryptoManager
|
||||
import com.rosetta.messenger.data.MessageRepository
|
||||
import com.rosetta.messenger.database.DialogEntity
|
||||
import com.rosetta.messenger.database.RosettaDatabase
|
||||
import com.rosetta.messenger.database.BlacklistEntity
|
||||
import com.rosetta.messenger.network.PacketOnlineSubscribe
|
||||
import com.rosetta.messenger.network.PacketSearch
|
||||
import com.rosetta.messenger.network.ProtocolManager
|
||||
|
||||
@@ -228,8 +228,8 @@ fun MessageInputBar(
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp)
|
||||
.padding(bottom = 16.dp)
|
||||
.padding(horizontal = 12.dp, vertical = 16.dp)
|
||||
.padding(bottom = 20.dp)
|
||||
.navigationBarsPadding(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.Center
|
||||
|
||||
Reference in New Issue
Block a user