Compare commits

..

No commits in common. "ab6eda1a4ca2f28613aaabe1c09d153a38c2f94c" and "2b71b7da0826ac867e9a8946eb9bcbb0b0a34830" have entirely different histories.

3 changed files with 18 additions and 29 deletions

2
.gitignore vendored
View file

@ -1,2 +0,0 @@
*.o
*.out

View file

@ -46,12 +46,7 @@ namespace Brainlet {
} Channel; } Channel;
typedef struct { typedef struct {
std::string id; std::string authorId;
std::string username;
} MessageAuthor;
typedef struct {
MessageAuthor author;
std::string message; std::string message;
} Message; } Message;
@ -276,12 +271,8 @@ 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 = {
.author = author, .authorId = data["author"]["_id"].asString(),
.message = data["content"].asString() .message = data["content"].asString()
}; };
if (client->onNewMessage) if (client->onNewMessage)

View file

@ -27,25 +27,25 @@
#include <vector> #include <vector>
#include <string> #include <string>
static std::unique_ptr<Brainlet::Client> client = nullptr; std::unique_ptr<Brainlet::Client> client = nullptr;
static std::unordered_map<Gtk::ListBoxRow*, std::string> channelRowToId; std::unordered_map<Gtk::ListBoxRow*, std::string> channelRowToId;
static std::unordered_map<std::string, std::vector<Brainlet::Message>> messages; std::unordered_map<std::string, std::vector<Brainlet::Message>> messages;
static std::string currentChannelId; std::string currentChannelId;
static Gtk::Window* window; Gtk::Window* window;
static Gtk::Widget* loginInterface; Gtk::Widget* loginInterface;
static Gtk::Entry* domainEntry; Gtk::Entry* domainEntry;
static Gtk::Entry* usernameEntry; Gtk::Entry* usernameEntry;
static Gtk::Entry* passwordEntry; Gtk::Entry* passwordEntry;
static Gtk::Button* loginButton; Gtk::Button* loginButton;
static Gtk::Widget* chatInterface; Gtk::Widget* chatInterface;
static Gtk::ListBox* channelList; Gtk::ListBox* channelList;
static Gtk::ListBox* messageList; Gtk::ListBox* messageList;
static Gtk::Entry* messageEntry; Gtk::Entry* messageEntry;
static Gtk::Label* usernameLabel; Gtk::Label* usernameLabel;
gboolean update(gpointer) { gboolean update(gpointer) {
client->processNextEvent(); client->processNextEvent();
@ -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.author.username + ": " + message.message; std::string messageFormatted = message.authorId + ": " + message.message;
text->set_markup(messageFormatted.c_str()); text->set_markup(messageFormatted.c_str());
row->add(*text); row->add(*text);