refactor: redesign format selection with unified list and independent audio/video picking
All checks were successful
CI / build (push) Successful in 52s
All checks were successful
CI / build (push) Successful in 52s
- Replace type/quality selection flow with unified format list (video+audio combined) - Add independent audio/video format picking: video-only formats prompt for audio track, audio-only formats offer optional video addition (skip when content is audio-only) - Fix formatKeyboard to use format IDs as callback data instead of display labels - Remove dead mediaTypeKeyboard function - Fix double-close panic in readProgress (caller is sole owner of updates channel) - Add FormatString field to DownloadJob for composite format specs (e.g. '137+140') - Change quota calculation from sum of all format sizes to max single format size - Fix 'Delete all data' button to use danger style with proper text - Clean up routePrefixedCallback: remove type_/quality_, add format_/secondary_ routes - Fix back navigation to rebuild format IDs list
This commit is contained in:
@@ -40,27 +40,14 @@ func settingsBackKeyboard() models.InlineKeyboardMarkup {
|
||||
}
|
||||
}
|
||||
|
||||
// mediaTypeKeyboard builds the three-button row for media type selection + Cancel.
|
||||
func mediaTypeKeyboard() models.InlineKeyboardMarkup {
|
||||
return models.InlineKeyboardMarkup{
|
||||
InlineKeyboard: [][]models.InlineKeyboardButton{
|
||||
{
|
||||
{Text: "Audio Only", CallbackData: "type_audio"},
|
||||
{Text: "Video Only", CallbackData: "type_video"},
|
||||
{Text: "Video+Audio", CallbackData: "type_both"},
|
||||
},
|
||||
{{Text: "Cancel", CallbackData: "cancel_dl"}},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// formatKeyboard builds a keyboard from a slice of format labels.
|
||||
func formatKeyboard(prefix string, labels []string) models.InlineKeyboardMarkup {
|
||||
// formatKeyboard builds a 2-column inline keyboard from labels with corresponding callback data values.
|
||||
// The prefix is prepended to each data value to form the full callback data.
|
||||
func formatKeyboard(prefix string, labels, data []string) models.InlineKeyboardMarkup {
|
||||
rows := [][]models.InlineKeyboardButton{}
|
||||
row := []models.InlineKeyboardButton{}
|
||||
for i, label := range labels {
|
||||
data := prefix + label
|
||||
row = append(row, models.InlineKeyboardButton{Text: label, CallbackData: data})
|
||||
cb := prefix + data[i]
|
||||
row = append(row, models.InlineKeyboardButton{Text: label, CallbackData: cb})
|
||||
if len(row) == 2 || i == len(labels)-1 {
|
||||
rows = append(rows, row)
|
||||
row = nil
|
||||
@@ -75,21 +62,7 @@ func formatKeyboard(prefix string, labels []string) models.InlineKeyboardMarkup
|
||||
|
||||
// languageKeyboard builds a keyboard from available languages.
|
||||
func languageKeyboard(languages []string) models.InlineKeyboardMarkup {
|
||||
rows := [][]models.InlineKeyboardButton{}
|
||||
row := []models.InlineKeyboardButton{}
|
||||
for i, lang := range languages {
|
||||
data := "lang_" + lang
|
||||
row = append(row, models.InlineKeyboardButton{Text: lang, CallbackData: data})
|
||||
if len(row) == 2 || i == len(languages)-1 {
|
||||
rows = append(rows, row)
|
||||
row = nil
|
||||
}
|
||||
}
|
||||
rows = append(rows, []models.InlineKeyboardButton{
|
||||
{Text: "Back", CallbackData: "back_step"},
|
||||
{Text: "Cancel", CallbackData: "cancel_dl"},
|
||||
})
|
||||
return models.InlineKeyboardMarkup{InlineKeyboard: rows}
|
||||
return formatKeyboard("lang_", languages, languages)
|
||||
}
|
||||
|
||||
// containerKeyboard builds keyboard for container format selection.
|
||||
@@ -214,7 +187,7 @@ func deleteConfirmKeyboard(userID int64) models.InlineKeyboardMarkup {
|
||||
return models.InlineKeyboardMarkup{
|
||||
InlineKeyboard: [][]models.InlineKeyboardButton{
|
||||
{
|
||||
{Text: "Yes, delete everything", CallbackData: fmt.Sprintf("delaccount_%d", userID)},
|
||||
{Text: "Yes, delete everything", CallbackData: fmt.Sprintf("delaccount_%d", userID), Style: "danger"},
|
||||
{Text: "Cancel", CallbackData: "back_settings"},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user