Refactor action definition

- Make an empty message type optional mean "no message"
- Set message type for all actions that send a message through the normal mechanism
- Remove now redundant bool specifying whether a message should be sent
This commit is contained in:
Tobias Fella
2024-12-22 20:45:51 +01:00
parent 2acc08402f
commit 71349b575b
4 changed files with 19 additions and 54 deletions

View File

@@ -309,7 +309,7 @@ void ChatBarCache::postMessage()
}
const auto result = ActionsModel::handleAction(room, this);
if (!result.first.has_value()) {
if (!result.second.has_value()) {
return;
}
@@ -338,8 +338,7 @@ void ChatBarCache::postMessage()
relatesTo = Quotient::EventRelation::replyTo(replyId());
}
const auto type = std::get<std::optional<Quotient::RoomMessageEvent::MsgType>>(result);
room->post<Quotient::RoomMessageEvent>(text(), type ? *type : Quotient::RoomMessageEvent::MsgType::Text, std::move(content), relatesTo);
room->post<Quotient::RoomMessageEvent>(text(), *std::get<std::optional<Quotient::RoomMessageEvent::MsgType>>(result), std::move(content), relatesTo);
clearCache();
}