2019-02-12 19:22:37 +01:00
|
|
|
/* Copyright 2018 Conny Duck
|
|
|
|
*
|
|
|
|
* This file is a part of Tusky.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with Tusky; if not,
|
|
|
|
* see <http://www.gnu.org/licenses>. */
|
|
|
|
|
|
|
|
package com.keylesspalace.tusky.db
|
|
|
|
|
2021-06-17 18:54:56 +02:00
|
|
|
import androidx.paging.PagingSource
|
|
|
|
import androidx.room.Dao
|
|
|
|
import androidx.room.Insert
|
|
|
|
import androidx.room.OnConflictStrategy
|
|
|
|
import androidx.room.Query
|
2019-02-12 19:22:37 +01:00
|
|
|
import com.keylesspalace.tusky.components.conversation.ConversationEntity
|
|
|
|
|
|
|
|
@Dao
|
|
|
|
interface ConversationsDao {
|
|
|
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
2021-06-17 18:54:56 +02:00
|
|
|
suspend fun insert(conversations: List<ConversationEntity>)
|
2019-02-12 19:22:37 +01:00
|
|
|
|
|
|
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
2022-05-30 19:06:14 +02:00
|
|
|
suspend fun insert(conversation: ConversationEntity)
|
2019-02-12 19:22:37 +01:00
|
|
|
|
2022-04-15 13:20:27 +02:00
|
|
|
@Query("DELETE FROM ConversationEntity WHERE id = :id AND accountId = :accountId")
|
2022-05-30 19:06:14 +02:00
|
|
|
suspend fun delete(id: String, accountId: Long)
|
2019-02-12 19:22:37 +01:00
|
|
|
|
2022-05-30 19:06:14 +02:00
|
|
|
@Query("SELECT * FROM ConversationEntity WHERE accountId = :accountId ORDER BY `order` ASC")
|
2021-06-28 21:13:24 +02:00
|
|
|
fun conversationsForAccount(accountId: Long): PagingSource<Int, ConversationEntity>
|
2019-02-12 19:22:37 +01:00
|
|
|
|
|
|
|
@Query("DELETE FROM ConversationEntity WHERE accountId = :accountId")
|
2022-05-30 19:06:14 +02:00
|
|
|
suspend fun deleteForAccount(accountId: Long)
|
2019-02-12 19:22:37 +01:00
|
|
|
}
|