From 454bd204b85fffeebd08d7f46154aa0126c11ce6 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Wed, 12 Oct 2022 22:02:01 +0200 Subject: [PATCH] Fix error creating a table --- Sources/App/Management/TableManagement.swift | 2 +- Sources/App/Model/Tables/WaitingTable.swift | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/App/Management/TableManagement.swift b/Sources/App/Management/TableManagement.swift index d2afe80..06063b7 100644 --- a/Sources/App/Management/TableManagement.swift +++ b/Sources/App/Management/TableManagement.swift @@ -43,7 +43,7 @@ final class TableManagement { try await table.create(on: database) player.$table.id = table.id try await player.update(on: database) - let waitingTable = WaitingTable(newTable: table) + let waitingTable = WaitingTable(newTable: table, user: player) self.tables[waitingTable.id] = waitingTable return waitingTable.tableInfo(forPlayer: player.name) } diff --git a/Sources/App/Model/Tables/WaitingTable.swift b/Sources/App/Model/Tables/WaitingTable.swift index 2be99dd..338a194 100644 --- a/Sources/App/Model/Tables/WaitingTable.swift +++ b/Sources/App/Model/Tables/WaitingTable.swift @@ -23,10 +23,9 @@ final class WaitingTable: AbstractTable { /** Create a new table. - Parameter name: The name of the table - - Parameter isPublic: The table is visible and joinable by everyone + - Parameter player: The user who created the table */ - init(newTable object: Table) { - let user = object.players[0] + init(newTable object: Table, user: User) { let player = WaitingPlayer(name: user.name, points: user.points) player.isNextActor = true super.init(id: object.id!, name: object.name, isPublic: object.isPublic, players: [player])