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::BeginMenuBar()) {
ImGui::Checkbox("show extra info", &_show_chat_extra_info);
if (ImGui::SmallButton("test")) {
_cr.emplace_or_replace<Contact::Components::AvatarFile>(*_selected_contact, "tomato_v1_256.png");
_cr.emplace_or_replace<Contact::Components::TagAvatarInvalidate>(*_selected_contact);
std::cout << "DEBUG: added AvatarFile comp to contact\n";
if (ImGui::BeginMenu("debug")) {
ImGui::Checkbox("show extra info", &_show_chat_extra_info);
ImGui::Checkbox("show avatar transfers", &_show_chat_avatar_tf);
ImGui::EndMenu();
}
ImGui::EndMenuBar();
}
@ -466,7 +466,13 @@ void ChatGui4::renderMessageBodyText(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
ImGui::TextDisabled("set avatar");
return;

View File

@ -31,7 +31,8 @@ class ChatGui4 {
// TODO: per contact
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_HEIGHT {1};

View File

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