fix: crash on context menu

This commit is contained in:
ZavaruKitsu 2023-07-08 01:02:17 +00:00
parent acb335ea2b
commit ea8f08269e
2 changed files with 19 additions and 17 deletions

View file

@ -68,11 +68,11 @@ namespace AyuSync {
}
void ayu_sync_controller::invokeHandler(json p) {
DEBUG_LOG(("Invoking handler on %1").arg(p.dump().c_str()));
LOG(("Invoking handler on %1").arg(p.dump().c_str()));
auto userId = p["userId"].get<long>();
auto type = p["type"].get<std::string>();
DEBUG_LOG(("userId: %1, type: %1").arg(userId).arg(type.c_str()));
LOG(("userId: %1, type: %1").arg(userId).arg(type.c_str()));
}
}

View file

@ -1079,23 +1079,25 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
}
}
if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty())) {
result->addAction(QString("History"), [=] {
auto box = Box<AyuUi::MessageHistoryBox>(item);
Ui::show(std::move(box));
}, &st::menuIconInfo);
if (item != nullptr) {
if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty())) {
result->addAction(QString("History"), [=] {
auto box = Box<AyuUi::MessageHistoryBox>(item);
Ui::show(std::move(box));
}, &st::menuIconInfo);
}
const auto settings = &AyuSettings::getInstance();
const auto history = item->history();
result->addAction(QString("Hide"), [=]() {
const auto initKeepDeleted = settings->keepDeletedMessages;
settings->set_keepDeletedMessages(false);
history->destroyMessage(item);
settings->set_keepDeletedMessages(initKeepDeleted);
}, &st::menuIconClear);
}
const auto settings = &AyuSettings::getInstance();
const auto history = item->history();
result->addAction(QString("Hide"), [=]() {
const auto initKeepDeleted = settings->keepDeletedMessages;
settings->set_keepDeletedMessages(false);
history->destroyMessage(item);
settings->set_keepDeletedMessages(initKeepDeleted);
}, &st::menuIconClear);
if (!view || !list->hasCopyRestriction(view->data())) {
AddCopyLinkAction(result, link);
}