refactor(tgbot-front): small cosmetics
This commit is contained in:
parent
7e0222d6f1
commit
a7b47c564a
2 changed files with 10 additions and 16 deletions
|
|
@ -105,8 +105,7 @@ private:
|
|||
|
||||
/// @brief Отрисовка текущего экрана (соотв. контексту)
|
||||
/// @param ctx - текущий контекст
|
||||
/// @return HandlerResult для нового состояния сообщения
|
||||
HandlerResult renderCurrent(TgBot::CallbackQuery::Ptr query, const UserContext& ctx);
|
||||
void renderCurrent(TgBot::CallbackQuery::Ptr query, const UserContext& ctx);
|
||||
|
||||
/// @brief Логика переходов между контекстами (навигация на следующий шаг)
|
||||
/// @param query - запрос
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ void BotHandlers::handleNavigation(TgBot::CallbackQuery::Ptr query, UserContext&
|
|||
|
||||
ctx.history.back().payload = newPayload;
|
||||
|
||||
auto result = renderCurrent(query, ctx);
|
||||
if(result.message == "meow") return; // TODO: убрать
|
||||
editMessage(chatId, messageId, result);
|
||||
renderCurrent(query, ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -42,13 +40,11 @@ void BotHandlers::handleNavigation(TgBot::CallbackQuery::Ptr query, UserContext&
|
|||
sendError(chatId, messageId, BotConstants::Text::SAD_ERROR);
|
||||
return;
|
||||
}
|
||||
auto result = renderCurrent(query, ctx);
|
||||
if(result.message == "meow") return; // TODO: убрать
|
||||
editMessage(chatId, messageId, result);
|
||||
renderCurrent(query, ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
// Переходы вперёд (pyush)
|
||||
// Переходы вперёд (push)
|
||||
auto newStepOpt = computeNextStep(query, current);
|
||||
if (!newStepOpt.has_value()) {
|
||||
sendError(chatId, messageId, BotConstants::Text::SAD_ERROR);
|
||||
|
|
@ -56,19 +52,18 @@ void BotHandlers::handleNavigation(TgBot::CallbackQuery::Ptr query, UserContext&
|
|||
}
|
||||
|
||||
ctx.history.push_back(*newStepOpt);
|
||||
auto result = renderCurrent(query, ctx);
|
||||
if(result.message == "meow") return; // TODO: убрать
|
||||
editMessage(chatId, messageId, result);
|
||||
renderCurrent(query, ctx);
|
||||
}
|
||||
|
||||
HandlerResult BotHandlers::renderCurrent(TgBot::CallbackQuery::Ptr query, const UserContext& ctx) {
|
||||
void BotHandlers::renderCurrent(TgBot::CallbackQuery::Ptr query, const UserContext& ctx) {
|
||||
const auto& step = ctx.history.back();
|
||||
//int64_t userId = query->from->id;
|
||||
int64_t chatId = query->message->chat->id;
|
||||
int64_t messageId = query->message->messageId;
|
||||
switch (step.state) {
|
||||
case UserState::MAIN_MENU:
|
||||
return showMainMenu();
|
||||
editMessage(chatId, messageId, showMainMenu());
|
||||
return;
|
||||
case UserState::VIEWING_MY_TITLES:
|
||||
server_.fetchUserTitlesAsync(std::to_string(2)) // ALARM: тестовое значение вместо userId
|
||||
.then([this, chatId, messageId](pplx::task<std::vector<BotStructs::Title>> t) {
|
||||
|
|
@ -86,7 +81,7 @@ HandlerResult BotHandlers::renderCurrent(TgBot::CallbackQuery::Ptr query, const
|
|||
}
|
||||
});
|
||||
|
||||
return {"meow", nullptr};
|
||||
return;
|
||||
/*
|
||||
case UserState::VIEWING_TITLE_PAGE:
|
||||
return returnTitlePage(step.payload); // payload = titleId
|
||||
|
|
@ -97,7 +92,7 @@ HandlerResult BotHandlers::renderCurrent(TgBot::CallbackQuery::Ptr query, const
|
|||
// ...
|
||||
*/
|
||||
default:
|
||||
return HandlerResult{BotConstants::Text::SAD_ERROR, nullptr};
|
||||
return editMessage(chatId, messageId, HandlerResult{BotConstants::Text::SAD_ERROR, nullptr});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue