Allow to change position of attachments

This commit is contained in:
Eike Kettner
2020-05-24 17:29:28 +02:00
parent 6807ce4d2f
commit 3cb738568f
6 changed files with 123 additions and 1 deletions

View File

@ -75,6 +75,8 @@ trait OItem[F[_]] {
def findByFileSource(checksum: String, sourceId: Ident): F[Vector[RItem]]
def deleteAttachment(id: Ident, collective: Ident): F[Int]
def moveAttachmentBefore(itemId: Ident, source: Ident, target: Ident): F[AddResult]
}
object OItem {
@ -121,6 +123,16 @@ object OItem {
def apply[F[_]: Effect](store: Store[F]): Resource[F, OItem[F]] =
Resource.pure[F, OItem[F]](new OItem[F] {
def moveAttachmentBefore(
itemId: Ident,
source: Ident,
target: Ident
): F[AddResult] =
store
.transact(QItem.moveAttachmentBefore(itemId, source, target))
.attempt
.map(AddResult.fromUpdate)
def findItem(id: Ident, collective: Ident): F[Option[ItemData]] =
store
.transact(QItem.findItem(id))