small debuggabilty improvements (scouting for an avatar bug)

This commit is contained in:
Green Sky 2023-10-21 18:07:06 +02:00
parent 869edb8d84
commit e7db39d20a
No known key found for this signature in database
4 changed files with 21 additions and 12 deletions

View File

@ -154,11 +154,11 @@ void ChatGui4::render(void) {
if (ImGui::BeginChild("message_log", {0, -100}, false, ImGuiWindowFlags_MenuBar)) { if (ImGui::BeginChild("message_log", {0, -100}, false, ImGuiWindowFlags_MenuBar)) {
if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenuBar()) {
if (ImGui::BeginMenu("debug")) {
ImGui::Checkbox("show extra info", &_show_chat_extra_info); ImGui::Checkbox("show extra info", &_show_chat_extra_info);
if (ImGui::SmallButton("test")) { ImGui::Checkbox("show avatar transfers", &_show_chat_avatar_tf);
_cr.emplace_or_replace<Contact::Components::AvatarFile>(*_selected_contact, "tomato_v1_256.png");
_cr.emplace_or_replace<Contact::Components::TagAvatarInvalidate>(*_selected_contact); ImGui::EndMenu();
std::cout << "DEBUG: added AvatarFile comp to contact\n";
} }
ImGui::EndMenuBar(); ImGui::EndMenuBar();
} }
@ -466,7 +466,13 @@ void ChatGui4::renderMessageBodyText(Message3Registry& reg, const Message3 e) {
} }
void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
if (reg.all_of<Message::Components::Transfer::FileKind>(e) && reg.get<Message::Components::Transfer::FileKind>(e).kind == 1) { if (
!_show_chat_avatar_tf
&& (
reg.all_of<Message::Components::Transfer::FileKind>(e)
&& reg.get<Message::Components::Transfer::FileKind>(e).kind == 1
)
) {
// TODO: this looks ugly // TODO: this looks ugly
ImGui::TextDisabled("set avatar"); ImGui::TextDisabled("set avatar");
return; return;

View File

@ -31,7 +31,8 @@ class ChatGui4 {
// TODO: per contact // TODO: per contact
std::string _text_input_buffer; std::string _text_input_buffer;
bool _show_chat_extra_info {true}; bool _show_chat_extra_info {false};
bool _show_chat_avatar_tf {false};
float TEXT_BASE_WIDTH {1}; float TEXT_BASE_WIDTH {1};
float TEXT_BASE_HEIGHT {1}; float TEXT_BASE_HEIGHT {1};

View File

@ -109,7 +109,7 @@ void SettingsWindow::render(void) {
if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenuBar()) {
ImGui::Separator(); ImGui::Separator();
if (ImGui::BeginMenu("Settings")) { if (ImGui::BeginMenu("Settings")) {
if (ImGui::MenuItem("show settings window")) { if (ImGui::MenuItem("settings window")) {
_show_window = true; _show_window = true;
} }
ImGui::EndMenu(); ImGui::EndMenu();

View File

@ -140,14 +140,14 @@ void ToxAvatarManager::checkMsg(Message3Handle h) {
const auto& file_info = h.get<Message::Components::Transfer::FileInfo>(); const auto& file_info = h.get<Message::Components::Transfer::FileInfo>();
const auto contact = h.get<Message::Components::ContactFrom>().c;
// TCS-2.2.4 // TCS-2.2.4
if (file_info.total_size > 65536ul) { if (file_info.total_size > 65536ul) {
// TODO: mark handled? // TODO: mark handled?
return; // too large return; // too large
} }
const auto contact = h.get<Message::Components::ContactFrom>().c;
// TCS-2.2.10 // TCS-2.2.10
if (file_info.file_list.empty() || file_info.file_list.front().file_name.empty() || file_info.total_size == 0) { if (file_info.file_list.empty() || file_info.file_list.front().file_name.empty() || file_info.total_size == 0) {
// reset // reset
@ -186,16 +186,18 @@ void ToxAvatarManager::checkMsg(Message3Handle h) {
h.emplace_or_replace<Components::TagAvatarImageHandled>(); h.emplace_or_replace<Components::TagAvatarImageHandled>();
} else { } else {
const auto& supposed_file_hash = h.get<Message::Components::Transfer::FileID>().id;
// check file id for existing hash // check file id for existing hash
if (std::filesystem::is_regular_file(file_path)) { if (std::filesystem::is_regular_file(file_path)) {
//const auto& supposed_file_hash = h.get<Message::Components::Transfer::FileID>().id;
// load file // load file
// hash file // hash file
//_t.toxHash(); //_t.toxHash();
std::filesystem::remove(file_path); // hack, hard replace existing file
} }
std::cout << "TAM: accepted avatar ft\n";
// if not already on disk // if not already on disk
_accept_queue.push_back(AcceptEntry{h, file_path}); _accept_queue.push_back(AcceptEntry{h, file_path});
} }