From ea81004599efcf7d4ab02f027546458e5b24f21b Mon Sep 17 00:00:00 2001 From: eikek Date: Wed, 11 Aug 2021 23:28:41 +0200 Subject: [PATCH] Fix updating alias with existing members --- .../backend/src/main/scala/sharry/backend/alias/OAlias.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/backend/src/main/scala/sharry/backend/alias/OAlias.scala b/modules/backend/src/main/scala/sharry/backend/alias/OAlias.scala index 044754de..a6d7ee3e 100644 --- a/modules/backend/src/main/scala/sharry/backend/alias/OAlias.scala +++ b/modules/backend/src/main/scala/sharry/backend/alias/OAlias.scala @@ -64,10 +64,11 @@ object OAlias { detail: AliasInput ): F[AddResult] = { val doUpdate = for { + _ <- RAliasMember.deleteForAlias(aliasId) n <- RAlias.update(aliasId, accId, detail.alias) k <- - if (n > 0) RAliasMember.updateForAlias(aliasId, detail.members) - else 0.pure[ConnectionIO] + if (n > 0) RAliasMember.insertForAlias(detail.alias.id, detail.members) + else RAliasMember.insertForAlias(aliasId, detail.members) } yield n + k for {