Skip to content

Commit

Permalink
Fix date in game chat message
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-battaglia committed Oct 20, 2023
1 parent a74eb0c commit d96fb5d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[ngClass]="{'is-align-self-flex-end': message.user.name === currentUser}">
<bal-card-subtitle>
{{ message.timestamp.toLocaleString() }}
<bal-tag [color]="message.user.color" [light]="message.user.name === currentUser">
<bal-tag [color]="message.user.color" [light]="message.user.name === currentUser" class="ml-small">
{{ message.user.name }}
</bal-tag>
</bal-card-subtitle>
Expand Down
2 changes: 0 additions & 2 deletions angular-frontend/src/app/components/chat/chat.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ export class ChatComponent implements OnInit, OnDestroy {
addMessage(payload: any) {
const newMessage = JSON.parse(payload.body) as ChatMessage;
newMessage.timestamp = new Date(newMessage.timestamp);
console.log(newMessage);
this.messages.push(newMessage);
}

sendMessage() {
const text = this.messageText
if (text !== "") {
const payload = JSON.stringify({text: text, clientTimestamp: new Date()});
console.log(payload);
this.client.publish({destination: "/app/chat", body: payload});
this.messageText = "";
this.chatMessageBox.nativeElement.focus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public OutgoingChatMessageDTO handleChatMessage(Message<String> message) throws

public void sendSystemChatMessage(String chatMessage) {
var systemUserDTO = new UserDTO("System", "danger");
var message = new OutgoingChatMessageDTO(chatMessage, systemUserDTO, new Date().toString());
var message = new OutgoingChatMessageDTO(chatMessage, systemUserDTO, new Date());
messagingTemplate.convertAndSend("/topic/chat", message);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.baloise.collab.springbackend.chat;

import java.util.Date;

public record IncomingChatMessageDTO(
String text,
String clientTimestamp
Date clientTimestamp
) {}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.baloise.collab.springbackend.chat;

import java.util.Date;

import com.baloise.collab.springbackend.useradmin.UserDTO;

public record OutgoingChatMessageDTO(
String text,
UserDTO user,
String timestamp
Date timestamp
) {}

0 comments on commit d96fb5d

Please sign in to comment.