feat: Add requests handling in ChatsListViewModel and UI; implement RequestsScreen and RequestsSection for better user interaction
This commit is contained in:
@@ -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>
|
||||
|
||||
/**
|
||||
* Получить диалог
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user