initial sqlite, store user

This commit is contained in:
ouwou
2020-11-19 19:18:59 -05:00
parent 1463d8da9e
commit deb482a8db
13 changed files with 381 additions and 78 deletions

View File

@@ -416,9 +416,9 @@ void ChatMessageItemContainer::HandleUserMentions(Gtk::TextView *tv) {
int mstart, mend;
if (!match.fetch_pos(0, mstart, mend)) break;
const Glib::ustring user_id = match.fetch(1);
const auto *user = discord.GetUser(user_id);
const auto user = discord.GetUser(user_id);
const auto *channel = discord.GetChannel(ChannelID);
if (user == nullptr || channel == nullptr) {
if (!user.has_value() || channel == nullptr) {
startpos = mend;
continue;
}
@@ -814,8 +814,8 @@ void ChatMessageHeader::UpdateNameColor() {
const auto &discord = Abaddon::Get().GetDiscordClient();
const auto guild_id = discord.GetChannel(ChannelID)->GuildID;
const auto role_id = discord.GetMemberHoistedRole(guild_id, UserID, true);
const auto *user = discord.GetUser(UserID);
if (user == nullptr) return;
const auto user = discord.GetUser(UserID);
if (!user.has_value()) return;
const auto *role = discord.GetRole(role_id);
std::string md;

View File

@@ -179,8 +179,8 @@ void ChatWindow::ProcessNewMessage(Snowflake id, bool prepend) {
} else {
const auto guild_id = client.GetChannel(m_active_channel)->GuildID;
const auto user_id = data->Author.ID;
const auto *user = client.GetUser(user_id);
if (user == nullptr) return;
const auto user = client.GetUser(user_id);
if (!user.has_value()) return;
header = Gtk::manage(new ChatMessageHeader(data));
header->signal_action_insert_mention().connect([this, user_id]() {

View File

@@ -112,13 +112,13 @@ void MemberList::UpdateMemberListInternal() {
// process all the shit first so its in proper order
std::map<int, const Role *> pos_to_role;
std::map<int, std::vector<const User *>> pos_to_users;
std::map<int, std::vector<User>> pos_to_users;
std::unordered_map<Snowflake, int> user_to_color;
std::vector<Snowflake> roleless_users;
for (const auto &id : ids) {
auto *user = discord.GetUser(id);
if (user == nullptr) {
auto user = discord.GetUser(id);
if (!user.has_value()) {
roleless_users.push_back(id);
continue;
}
@@ -134,7 +134,7 @@ void MemberList::UpdateMemberListInternal() {
};
pos_to_role[pos_role->Position] = pos_role;
pos_to_users[pos_role->Position].push_back(user);
pos_to_users[pos_role->Position].push_back(std::move(*user));
if (col_role != nullptr) {
if (ColorDistance(col_role->Color, 0xFFFFFF) < 15)
user_to_color[id] = 0x000000;
@@ -198,10 +198,10 @@ void MemberList::UpdateMemberListInternal() {
if (pos_to_users.find(pos) == pos_to_users.end()) continue;
auto &users = pos_to_users.at(pos);
AlphabeticalSort(users.begin(), users.end(), [](auto e) { return e->Username; });
AlphabeticalSort(users.begin(), users.end(), [](const auto &e) { return e.Username; });
for (const auto data : users)
add_user(data);
add_user(&data);
}
if (chan->Type == ChannelType::DM || chan->Type == ChannelType::GROUP_DM)
@@ -209,9 +209,9 @@ void MemberList::UpdateMemberListInternal() {
else
add_role("@everyone");
for (const auto &id : roleless_users) {
const auto *user = discord.GetUser(id);
if (user != nullptr)
add_user(user);
const auto user = discord.GetUser(id);
if (user.has_value())
add_user(&*user);
}
}