Display message in chat on subject change

This commit is contained in:
Jaidyn Ann 2021-08-11 19:46:33 -05:00
parent 3f754bd79d
commit fed3b9d9f0

View File

@ -120,7 +120,6 @@ ConversationView::ImMessage(BMessage* msg)
} }
case IM_MESSAGE_RECEIVED: case IM_MESSAGE_RECEIVED:
{ {
msg->AddInt64("when", (int64)time(NULL));
_AppendOrEnqueueMessage(msg); _AppendOrEnqueueMessage(msg);
fReceiveView->ScrollToBottom(); fReceiveView->ScrollToBottom();
break; break;
@ -137,7 +136,6 @@ ConversationView::ImMessage(BMessage* msg)
{ {
BMessage msg; BMessage msg;
msg.AddString("body", B_TRANSLATE("** You joined the room.\n")); msg.AddString("body", B_TRANSLATE("** You joined the room.\n"));
msg.AddInt64("when", (int64)time(NULL));
_AppendOrEnqueueMessage(&msg); _AppendOrEnqueueMessage(&msg);
fReceiveView->ScrollToBottom(); fReceiveView->ScrollToBottom();
} }
@ -145,7 +143,6 @@ ConversationView::ImMessage(BMessage* msg)
{ {
BMessage msg; BMessage msg;
msg.AddString("body", B_TRANSLATE("** You created the room.\n")); msg.AddString("body", B_TRANSLATE("** You created the room.\n"));
msg.AddInt64("when", (int64)time(NULL));
_AppendOrEnqueueMessage(&msg); _AppendOrEnqueueMessage(&msg);
fReceiveView->ScrollToBottom(); fReceiveView->ScrollToBottom();
} }
@ -289,6 +286,13 @@ ConversationView::ObserveString(int32 what, BString str)
case STR_ROOM_SUBJECT: case STR_ROOM_SUBJECT:
{ {
fSubjectTextView->SetText(str); fSubjectTextView->SetText(str);
BString body = B_TRANSLATE("** The subject was changed: %subject%");
body.ReplaceAll("%subject%", str);
BMessage topic(IM_MESSAGE);
topic.AddString("body", body);
_AppendOrEnqueueMessage(&topic);
break; break;
} }
} }
@ -377,6 +381,9 @@ ConversationView::_InitInterface()
bool bool
ConversationView::_AppendOrEnqueueMessage(BMessage* msg) ConversationView::_AppendOrEnqueueMessage(BMessage* msg)
{ {
if (msg->HasInt64("when") == false)
msg->AddInt64("when", (int64)time(NULL));
// If not attached to the chat window, then re-handle this message // If not attached to the chat window, then re-handle this message
// later [AttachedToWindow()], since you can't edit an unattached // later [AttachedToWindow()], since you can't edit an unattached
// RenderView. // RenderView.
@ -459,7 +466,6 @@ ConversationView::_UserMessage(const char* format, const char* bodyFormat,
BMessage newMsg; BMessage newMsg;
newMsg.AddString("body", newBody); newMsg.AddString("body", newBody);
newMsg.AddInt64("when", (int64)time(NULL));
_AppendOrEnqueueMessage(&newMsg); _AppendOrEnqueueMessage(&newMsg);
fReceiveView->ScrollToBottom(); fReceiveView->ScrollToBottom();
} }