feat: Add requests handling in ChatsListViewModel and UI; implement RequestsScreen and RequestsSection for better user interaction

This commit is contained in:
k1ngsterr1
2026-01-16 18:08:34 +05:00
parent 6d506e681b
commit 7750f450e8
3 changed files with 253 additions and 5 deletions

View File

@@ -290,14 +290,52 @@ interface DialogDao {
/**
* Получить все диалоги отсортированные по последнему сообщению
* Исключает requests (диалоги без исходящих сообщений от нас)
*/
@Query("""
SELECT * FROM dialogs
WHERE account = :account
ORDER BY last_message_timestamp DESC
SELECT d.* FROM dialogs d
WHERE d.account = :account
AND EXISTS (
SELECT 1 FROM messages m
WHERE m.account = :account
AND m.from_public_key = :account
AND m.to_public_key = d.opponent_key
)
ORDER BY d.last_message_timestamp DESC
""")
fun getDialogsFlow(account: String): Flow<List<DialogEntity>>
/**
* Получить requests - диалоги где нам писали, но мы не отвечали
*/
@Query("""
SELECT d.* FROM dialogs d
WHERE d.account = :account
AND NOT EXISTS (
SELECT 1 FROM messages m
WHERE m.account = :account
AND m.from_public_key = :account
AND m.to_public_key = d.opponent_key
)
ORDER BY d.last_message_timestamp DESC
""")
fun getRequestsFlow(account: String): Flow<List<DialogEntity>>
/**
* Получить количество requests
*/
@Query("""
SELECT COUNT(*) FROM dialogs d
WHERE d.account = :account
AND NOT EXISTS (
SELECT 1 FROM messages m
WHERE m.account = :account
AND m.from_public_key = :account
AND m.to_public_key = d.opponent_key
)
""")
fun getRequestsCountFlow(account: String): Flow<Int>
/**
* Получить диалог
*/