Skip to content

Commit 4b9adfc

Browse files
committed
Fix outgoing messages not sending via MessageCenterEditor
1 parent 4bf2e0f commit 4b9adfc

3 files changed

Lines changed: 34 additions & 9 deletions

File tree

Source/Processors/MessageCenter/MessageCenter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ void MessageCenter::addOutgoingMessage (const String& msg, const int64 systemTim
147147
broadcastMessage (msg, systemTimeMilliseconds);
148148
addSavedMessage (msg);
149149

150-
if(messageCenterEditor != nullptr)
151-
messageCenterEditor->addOutgoingMessage (msg, systemTimeMilliseconds);
150+
if (messageCenterEditor != nullptr)
151+
messageCenterEditor->addOutgoingMessage (msg, systemTimeMilliseconds);
152152
}
153153

154154
void MessageCenter::addSavedMessage (const String& msg)
@@ -218,7 +218,7 @@ void MessageCenter::process (AudioBuffer<float>& buffer)
218218

219219
messageQueue.pop();
220220

221-
LOGC ("Message Center sending message: ", eventString);
221+
LOGD ("Message Center sending message: ", eventString);
222222

223223
newEventAvailable = false;
224224
}

Source/Processors/MessageCenter/MessageCenterEditor.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void MessageCenterEditor::buttonClicked (Button* button)
7777
{
7878
if (editableMessageDisplayArea->getText().length() > 0)
7979
{
80-
addOutgoingMessage (editableMessageDisplayArea->getText(), CoreServices::getSystemTime());
80+
messageCenter->addOutgoingMessage (editableMessageDisplayArea->getText(), CoreServices::getSystemTime());
8181
}
8282
}
8383

@@ -140,11 +140,13 @@ void MessageCenterEditor::addIncomingMessage (const String& message)
140140
{
141141
if (firstMessageReceived)
142142
incomingMessageLog->addMessage (new MessageLabel ("message",
143-
incomingMessageDisplayArea->getText()));
143+
incomingMessageDisplayArea->getText(),
144+
incomingMessageDisplayArea->getTimeString()));
144145
else
145146
firstMessageReceived = true;
146147

147148
incomingMessageDisplayArea->setText (message, sendNotification);
149+
incomingMessageDisplayArea->setTimeString (Time::getCurrentTime().toString (false, true, true, true));
148150

149151
incomingBackground = Colour (206, 172, 202);
150152
startTimer (75);
@@ -153,9 +155,13 @@ void MessageCenterEditor::addIncomingMessage (const String& message)
153155

154156
void MessageCenterEditor::addOutgoingMessage (const String& message, const int64 systemTime)
155157
{
158+
Time time (systemTime);
159+
String timeString = time.toString (false, true, true, true);
160+
outgoingMessageLog->addMessage (new MessageLabel ("message", message, timeString));
161+
156162
editableMessageDisplayArea->setText (message, dontSendNotification);
163+
editableMessageDisplayArea->setTimeString (timeString);
157164

158-
outgoingMessageLog->addMessage (new MessageLabel ("message", message));
159165
outgoingBackground = Colour (244, 208, 80);
160166

161167
resized();
@@ -309,15 +315,18 @@ void MessageCenterEditor::resized()
309315

310316
// #################################################################
311317

312-
MessageLabel::MessageLabel (const String& componentName, const String& labelText)
318+
MessageLabel::MessageLabel (const String& componentName, const String& labelText, const String& timeString_)
313319
: Label (componentName, labelText)
314320
{
315321
setJustificationType (Justification::bottomLeft);
316322
setFont (FontOptions ("CP Mono", "Plain", 16));
317323
setBorderSize (BorderSize<int> (0, 7, 2, 0));
318324
setMinimumHorizontalScale (1.0f);
319325

320-
timestring = Time::getCurrentTime().toString (false, true, true, true);
326+
if (timeString_.isNotEmpty())
327+
timestring = timeString_;
328+
else
329+
timestring = Time::getCurrentTime().toString (false, true, true, true);
321330
}
322331

323332
String MessageLabel::getTooltip()
@@ -330,6 +339,16 @@ void MessageLabel::prependText (String text)
330339
setText (text + getText(), dontSendNotification);
331340
}
332341

342+
void MessageLabel::setTimeString (const String& timeString_)
343+
{
344+
timestring = timeString_;
345+
}
346+
347+
String MessageLabel::getTimeString() const
348+
{
349+
return timestring;
350+
}
351+
333352
MessageLog::MessageLog (Viewport* vp) : viewport (vp),
334353
messageHeight (20)
335354
{

Source/Processors/MessageCenter/MessageCenterEditor.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@ class MessageLabel : public Label
3737
{
3838
public:
3939
/** Constructor */
40-
MessageLabel (const String& componentName = String(), const String& labelText = String());
40+
MessageLabel (const String& componentName = String(), const String& labelText = String(), const String& timeString = String());
4141

4242
/** Returns tooltip */
4343
String getTooltip();
4444

4545
/** Add text at the beginning of a string */
4646
void prependText (String text);
4747

48+
/** Sets the timestamp for the message */
49+
void setTimeString (const String& timeString);
50+
51+
/** Returns the timestamp for the message */
52+
String getTimeString() const;
53+
4854
private:
4955
/** Holds info about the time the message was sent or received */
5056
String timestring;

0 commit comments

Comments
 (0)