From 1d1044c3f823889ad7f3db4a8f0ac1f10ff83ab6 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Thu, 23 Dec 2021 12:52:28 +0100 Subject: [PATCH] Fix delete empty table --- Sources/App/Management/TableManagement.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/App/Management/TableManagement.swift b/Sources/App/Management/TableManagement.swift index 6de7c25..15aaf13 100644 --- a/Sources/App/Management/TableManagement.swift +++ b/Sources/App/Management/TableManagement.swift @@ -113,8 +113,9 @@ final class TableManagement { player.$table.id = nil guard let table = WaitingTable(oldTable: oldTable, removing: player.name) else { tables[oldTable.id] = nil - return Table.query(on: database).filter(\.$id == oldTable.id).delete().flatMap { - player.update(on: database) + return player.update(on: database).flatMap { + print("Updating player") + return Table.query(on: database).filter(\.$id == oldTable.id).delete() } } /// `player.canStartGame` is automatically set to false, because table is not full