EdJoPaTo / grammy-inline-menu

Inline Menus for Telegram made simple. Successor of telegraf-inline-menu.
MIT License
357 stars 44 forks source link

manually opening submenu #172

Closed gabrieljaegerde closed 3 years ago

gabrieljaegerde commented 3 years ago

i have a menu: lur this has a submenu: lco which in turn has a chooseintosubmenu: a

I am trying to render the chooseintosubmenu for a given item: 6175313354ab83168fd555b6

the following does not work and actually just renders lur/lco/ listUserRewardsMiddleware.replyToContext(ctx, lur/lco/a:6175313354ab83168fd555b6/);

if i however have the following, I am able to render lur/lco/a:6175313354ab83168fd555b6/ (but i render 2 menus instead of 1). listUserRewardsMiddleware.replyToContext(ctx, lur/lco/); listUserRewardsMiddleware.replyToContext(ctx, lur/lco/a:6175313354ab83168fd555b6/);

is this intended behavior? Is there a way to exclusively render lur/lco/a:6175313354ab83168fd555b6/ without having to render the previous menus in the tree first?

EdJoPaTo commented 3 years ago

This is actually a feature and can be disabled on each choose / select / chooseIntoSubmenu: https://github.com/EdJoPaTo/grammy-inline-menu/blob/78e3680d9f3e236cd801a4141b3a473e5069481b/source/choices/types.ts#L30-L37

I hope the comment already describes this well enough. I guess this should also be documented in the README somewhere? Not sure how to explain that both well enough for beginners and make it easily findable. Any ideas?

gabrieljaegerde commented 3 years ago

This does not solve it for me unfortunately. Could there be something else causing the "step-down redirect"?

EdJoPaTo commented 3 years ago

Currently I'm not sure what might cause it. Can you create a simplified example where it also fails to work?

gabrieljaegerde commented 3 years ago

perhaps seeing my code is of help? https://github.com/gabrieljaegerde/substrateGo_telegram/blob/master/src/finder/menus/postCollectionMenu.ts#L14

In the selected row I actually want to put: listUserRewardsMiddleware.replyToContext(ctx, "lur/lco/a:61768c8ba4cf483a387738c3/") <- this just always redirected to "lur/lco" while still keeping a:61768c8ba4cf483a387738c3/ in the path. so when i clicked on an item in "lur/lco" then, the path became lur/lco/a:61768c8ba4cf483a387738c3/a:61768c8ba4cf483a387738c3/

my "lur" middleware https://github.com/gabrieljaegerde/substrateGo_telegram/blob/master/src/finder/menus/listUserRewardsMenu.ts

and my "lco" middleware https://github.com/gabrieljaegerde/substrateGo_telegram/blob/master/src/finder/menus/listCollectedMenu.ts

i tried adding disableChoiceExistsCheck: true to the listCollected.chooseIntoSubmenu options but the behavior was still the same

EdJoPaTo commented 3 years ago

Something irrelevant I noticed: You can use new MenuTemplate<CustomContext>(…) and then omit the ctx: CustomContext type annotations. This should simplify some code.

I am still unsure how or what the reason for this behavior is. Personally I would try to replicate that behavior as simple as possible. Two Middlewares with their menus and so on. Unfortunately I don't have the time currently I would like to have to investigate here.

It would be interesting to see a minimal working example of that behavior. That would simplify finding the issue of that. Do you think you can replicate that behavior in a simple bot?

gabrieljaegerde commented 3 years ago

So the issue was actually that I included a hide option. Without the hide and with disableChoiceExistsCheck: true, it does work as expected. Since I actually didn't need the hide option, this solution worked for me.