Skip to content

Commit

Permalink
fix: fix player updated notification profile link (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc authored Mar 3, 2021
1 parent d5cd2c4 commit 32d3d44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/players/services/players.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ export class PlayersService implements OnModuleInit {
}

async updatePlayer(playerId: string, update: Partial<Player>, adminId?: string): Promise<Player> {
const oldPlayer = await this.playerModel.findById(playerId).lean().exec();
const oldPlayer = await this.playerModel.findById(playerId);
if (!oldPlayer) {
throw new Error('no such player');
}

const newPlayer = await this.playerModel.findOneAndUpdate({ _id: playerId }, update, { new: true }).lean().exec();
this.onlinePlayersService.getSocketsForPlayer(playerId).forEach(socket => socket.emit('profile update', { ...newPlayer }));
const newPlayer = await this.playerModel.findOneAndUpdate({ _id: playerId }, update, { new: true });
this.onlinePlayersService.getSocketsForPlayer(playerId).forEach(socket => socket.emit('profile update', newPlayer.toJSON()));
this.events.playerUpdates.next({ oldPlayer, newPlayer, adminId });
return newPlayer;
}
Expand Down

0 comments on commit 32d3d44

Please sign in to comment.