Skip to content

Commit

Permalink
Fix bio updates
Browse files Browse the repository at this point in the history
  • Loading branch information
outkine committed Mar 11, 2024
1 parent 8ad337c commit 40a5a97
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions app/controllers/RobotController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,29 @@ class RobotController @Inject()(
)
},
data => {
robotsRepo.findBare(user.id, data.name)(LoggedIn(user)) flatMap {
case Some(_) =>
Future successful BadRequest(
views.html.robot.update(
UpdateRobotForm.form
.fill(data)
.withGlobalError("Robot with this name already exists"),
robot,
assetsFinder
)
val success = () =>
robotsRepo.update(robot.id, data.name, data.bio, data.openSource) map { _ =>
Redirect(
routes.RobotController.view(user.username, data.name)
)
case None =>
robotsRepo.update(robot.id, data.name, data.bio, data.openSource) map { _ =>
Redirect(
routes.RobotController.view(user.username, data.name)
}
if (data.name != robot.name) {
robotsRepo.findBare(user.id, data.name)(LoggedIn(user)) flatMap {
case Some(_) =>
Future successful BadRequest(
views.html.robot.update(
UpdateRobotForm.form
.fill(data)
.withGlobalError("Robot with this name already exists"),
robot,
assetsFinder
)
)
}
case None =>
success()
}
} else {
success()
}
}
)
Expand Down

0 comments on commit 40a5a97

Please sign in to comment.