forked from hiimgoodpack/brainlet-client
display message author username instead of id
This commit is contained in:
parent
090418e1df
commit
ab6eda1a4c
2 changed files with 12 additions and 3 deletions
13
brainlet.h
13
brainlet.h
|
@ -46,7 +46,12 @@ namespace Brainlet {
|
||||||
} Channel;
|
} Channel;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
std::string authorId;
|
std::string id;
|
||||||
|
std::string username;
|
||||||
|
} MessageAuthor;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MessageAuthor author;
|
||||||
std::string message;
|
std::string message;
|
||||||
} Message;
|
} Message;
|
||||||
|
|
||||||
|
@ -271,8 +276,12 @@ namespace Brainlet {
|
||||||
.id = data["channel"]["_id"].asString(),
|
.id = data["channel"]["_id"].asString(),
|
||||||
.name = data["channel"]["title"].asString()
|
.name = data["channel"]["title"].asString()
|
||||||
};
|
};
|
||||||
|
MessageAuthor author = {
|
||||||
|
.id = data["author"]["_id"].asString(),
|
||||||
|
.username = data["author"]["username"].asString()
|
||||||
|
};
|
||||||
Message message = {
|
Message message = {
|
||||||
.authorId = data["author"]["_id"].asString(),
|
.author = author,
|
||||||
.message = data["content"].asString()
|
.message = data["content"].asString()
|
||||||
};
|
};
|
||||||
if (client->onNewMessage)
|
if (client->onNewMessage)
|
||||||
|
|
2
main.cpp
2
main.cpp
|
@ -80,7 +80,7 @@ void addMessage(const Brainlet::Message message) {
|
||||||
text->set_halign(Gtk::ALIGN_START);
|
text->set_halign(Gtk::ALIGN_START);
|
||||||
text->set_line_wrap(true);
|
text->set_line_wrap(true);
|
||||||
|
|
||||||
std::string messageFormatted = message.authorId + ": " + message.message;
|
std::string messageFormatted = message.author.username + ": " + message.message;
|
||||||
text->set_markup(messageFormatted.c_str());
|
text->set_markup(messageFormatted.c_str());
|
||||||
|
|
||||||
row->add(*text);
|
row->add(*text);
|
||||||
|
|
Reference in a new issue