Skip to content

Commit c69a381

Browse files
committed
2 parents 26a501f + 2d13800 commit c69a381

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/handlers/commands/start.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ void handleStartCmd(MessageRef m, BotRef bot, SMRef stateManager, api::ApiClient
4444
return;
4545
}
4646
const std::string_view payload = std::string_view{m.text}.substr("/start "sv.size());
47-
4847
if (payload.starts_with("invite_")) {
4948
const std::string_view hash = payload.substr("invite_"sv.size());
5049
auto storage = api.getStoragesApi().activate(userId, api::InvitationId{hash});

src/render/storage/ingredients/delete.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ std::vector<TgBot::InlineKeyboardButton::Ptr> constructNavigationButtons(std::si
1919
auto forward = makeCallbackButton(u8"▶️", "next");
2020
auto backward = makeCallbackButton(u8"◀️", "prev");
2121
auto dont_handle = makeCallbackButton(u8"", "dont_handle");
22-
auto page = makeCallbackButton(std::format("{} из {}", (pageNo + 1), (maxPageNum + 1)), "dont_handle");
22+
auto page = makeCallbackButton(std::format("{} из {}", (pageNo + 1), maxPageNum), "dont_handle");
2323
if (pageNo == maxPageNum) {
2424
buttons.push_back(backward);
2525
buttons.push_back(page);
@@ -71,7 +71,7 @@ constructMessage(std::vector<api::models::ingredient::Ingredient>& selectedIngre
7171
else
7272
buttonRows += 2; // + back + navig
7373
} else {
74-
if (ingSize <= numOfIngredientsOnPage) {
74+
if (ingSize <= numOfIngredientsOnPage && pageNo == 0) {
7575
if (withoutPutToShoppingListButton)
7676
buttonRows += 2; // + back + delete
7777
else

src/render/storage/members/add.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
#include "backend/id_types.hpp"
55
#include "message_tracker.hpp"
66
#include "render/common.hpp"
7+
#include "utils/u8format.hpp"
78
#include "utils/utils.hpp"
89

10+
#include <boost/url/url.hpp>
911
#include <tgbot/types/InlineKeyboardButton.h>
1012

1113
#include <cstddef>
@@ -39,11 +41,16 @@ void renderShareLinkMemberAddition(
3941

4042
auto inviteButton = std::make_shared<TgBot::InlineKeyboardButton>();
4143
inviteButton->text = utils::utf8str(u8"📤 Поделиться");
44+
const std::string botAlias = bot.getUnderlying().getMe()->username;
4245
const api::InvitationId hash = storageApi.inviteMember(userId, storageId);
43-
const std::string telegramBotAlias = bot.getUnderlying().getMe()->username;
44-
const std::string inviteText = "Нажми на ссылку, чтобы стать участником хранилища 🍱**" + storage.name +
45-
"** в CookCookhNya!\nhttps://t.me/" + telegramBotAlias + "?start=invite_" + hash;
46-
inviteButton->url = "https://t.me/share/url?url=" + inviteText;
46+
const std::string storageUrl = std::format("https://t.me/{}?start=invite_{}", botAlias, hash);
47+
const std::string shareText = utils::u8format(
48+
"{} **{}** {}", u8"Нажми на ссылку, чтобы стать участником хранилища 🍱", storage.name, "в CookCookhNya!");
49+
50+
boost::urls::url url{"https://t.me/share/url"};
51+
url.params().append({"url", storageUrl});
52+
url.params().append({"text", shareText});
53+
inviteButton->url = url.buffer();
4754

4855
keyboard[0].push_back(std::move(inviteButton));
4956
keyboard[1].push_back(makeCallbackButton(u8"↩️ Назад", "back"));

0 commit comments

Comments
 (0)