обработка обновлений последовательно для каждого юзера благодаря mutex
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"example.com/m/bot"
|
||||
"example.com/m/ui"
|
||||
"github.com/NicoNex/echotron/v3"
|
||||
)
|
||||
|
||||
@@ -555,15 +556,10 @@ func (s *PurchaseOptionalDetails) renderParamChannels(b *bot.Bot, mode bot.Rende
|
||||
return
|
||||
}
|
||||
|
||||
start := s.ParamPage * perPage
|
||||
if start >= total {
|
||||
if s.ParamPage*perPage >= total {
|
||||
s.ParamPage = 0
|
||||
start = 0
|
||||
}
|
||||
end := start + perPage
|
||||
if end > total {
|
||||
end = total
|
||||
}
|
||||
start, end := ui.GetPageBounds(s.ParamPage, perPage, total)
|
||||
|
||||
var rows [][]echotron.InlineKeyboardButton
|
||||
for i := start; i < end; i++ {
|
||||
@@ -577,20 +573,11 @@ func (s *PurchaseOptionalDetails) renderParamChannels(b *bot.Bot, mode bot.Rende
|
||||
))
|
||||
}
|
||||
|
||||
pages := (total + perPage - 1) / perPage
|
||||
if pages > 1 {
|
||||
var navRow []echotron.InlineKeyboardButton
|
||||
if s.ParamPage > 0 {
|
||||
navRow = append(navRow, bot.Button("←", "param_prev"))
|
||||
} else {
|
||||
navRow = append(navRow, bot.Button("·", "empty"))
|
||||
}
|
||||
navRow = append(navRow, bot.Button(fmt.Sprintf("• %d/%d •", s.ParamPage+1, pages), "page_info"))
|
||||
if s.ParamPage+1 < pages {
|
||||
navRow = append(navRow, bot.Button("→", "param_next"))
|
||||
} else {
|
||||
navRow = append(navRow, bot.Button("·", "empty"))
|
||||
}
|
||||
pages := ui.CalculatePages(total, perPage)
|
||||
if navRow := ui.BuildNavigationRow(ui.PaginationConfig{
|
||||
CurrentPage: s.ParamPage,
|
||||
TotalPages: pages,
|
||||
}); navRow != nil {
|
||||
rows = append(rows, navRow)
|
||||
}
|
||||
|
||||
@@ -688,13 +675,13 @@ func (s *PurchaseOptionalDetails) handleParamCallback(b *bot.Bot, data string) b
|
||||
s.applyParamToAll(param)
|
||||
s.Enter(b, bot.EditMessage)
|
||||
return true
|
||||
case data == "param_prev":
|
||||
case data == "prev" && strings.HasSuffix(s.InputMode, "_channels"):
|
||||
if s.ParamPage > 0 {
|
||||
s.ParamPage--
|
||||
}
|
||||
s.Enter(b, bot.EditMessage)
|
||||
return true
|
||||
case data == "param_next":
|
||||
case data == "next" && strings.HasSuffix(s.InputMode, "_channels"):
|
||||
s.ParamPage++
|
||||
s.Enter(b, bot.EditMessage)
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user