fix(robot): show the per-game name in REST game views, not the account name
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 50s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m18s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 50s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m18s
The seat display-name snapshot only reached the live-event path (seatNames);
the REST DTO layer still resolved seat names from the account store
(fillSeatNames), so the game screen and lobby list showed the robot's seeded
account name ("Женя") while the your_turn toast showed its per-game name
("Звёздный_Барс2"). Carry the snapshot into gameDTOFromGame and have
fillSeatNames fall back to the account only for a seat with no snapshot (a
pre-snapshot legacy row). Friends and invitations keep account names (the
persistent identity, not a per-game disguise).
This commit is contained in:
@@ -77,8 +77,9 @@ type moveRecordDTO struct {
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// seatDTO is one seat's public standing. DisplayName is resolved from the account
|
||||
// store by the handler (the game domain keys seats by account id only).
|
||||
// seatDTO is one seat's public standing. DisplayName is the seat's display-name snapshot
|
||||
// (the per-game name, frozen when the seat was taken); fillSeatNames fills it from the
|
||||
// account store only when a seat has no snapshot yet (a pre-snapshot legacy row).
|
||||
type seatDTO struct {
|
||||
Seat int `json:"seat"`
|
||||
AccountID string `json:"account_id"`
|
||||
@@ -199,19 +200,21 @@ const awayTimeLayout = "15:04"
|
||||
func gameDTOFromGame(g game.Game) gameDTO {
|
||||
seats := make([]seatDTO, 0, len(g.Seats))
|
||||
for _, s := range g.Seats {
|
||||
// An open game's still-empty opponent seat has no account: emit an empty id (the
|
||||
// display name is left empty by fillSeatNames) so the client shows "searching for
|
||||
// opponent" rather than the nil-UUID.
|
||||
// An open game's still-empty opponent seat has no account: emit an empty id (and an
|
||||
// empty display name) so the client shows "searching for opponent" rather than the
|
||||
// nil-UUID. DisplayName carries the seat's per-game snapshot; fillSeatNames fills
|
||||
// only the seats still without one from the account store.
|
||||
accountID := ""
|
||||
if s.AccountID != uuid.Nil {
|
||||
accountID = s.AccountID.String()
|
||||
}
|
||||
seats = append(seats, seatDTO{
|
||||
Seat: s.Seat,
|
||||
AccountID: accountID,
|
||||
Score: s.Score,
|
||||
HintsUsed: s.HintsUsed,
|
||||
IsWinner: s.IsWinner,
|
||||
Seat: s.Seat,
|
||||
AccountID: accountID,
|
||||
DisplayName: s.DisplayName,
|
||||
Score: s.Score,
|
||||
HintsUsed: s.HintsUsed,
|
||||
IsWinner: s.IsWinner,
|
||||
})
|
||||
}
|
||||
last := g.TurnStartedAt
|
||||
|
||||
Reference in New Issue
Block a user