fix: add missing confirmations to command handlers for consistency
All checks were successful
CI / build (push) Successful in 50s
All checks were successful
CI / build (push) Successful in 50s
All /setrate, /setcurrency, /settimezone, /setbreak, /setusername, /setreporttime now send a confirmation message, matching the UI flow. Also fixes rate confirmation to show the actual currency symbol.
This commit is contained in:
@@ -445,6 +445,12 @@ func (h *Handler) handleSetRate(ctx context.Context, msg *models.Message, user *
|
||||
return
|
||||
}
|
||||
h.saveRate(ctx, msg.Chat.ID, user, rate)
|
||||
st, _ := h.Repo.GetOrCreateSettings(user.ID)
|
||||
sym := "$"
|
||||
if st != nil && st.Currency != "" {
|
||||
sym = domain.CurrencySymbol(st.Currency)
|
||||
}
|
||||
h.sendText(ctx, msg.Chat.ID, fmt.Sprintf("Hourly rate set to %s%.2f", sym, rate))
|
||||
}
|
||||
|
||||
func (h *Handler) handleSetCurrency(ctx context.Context, msg *models.Message, user *domain.User) {
|
||||
@@ -460,6 +466,7 @@ func (h *Handler) handleSetCurrency(ctx context.Context, msg *models.Message, us
|
||||
return
|
||||
}
|
||||
h.saveCurrency(ctx, msg.Chat.ID, user, currency)
|
||||
h.sendText(ctx, msg.Chat.ID, fmt.Sprintf("Currency set to: %s", currency))
|
||||
}
|
||||
|
||||
func (h *Handler) handleSetTimezone(ctx context.Context, msg *models.Message, user *domain.User) {
|
||||
@@ -474,6 +481,9 @@ func (h *Handler) handleSetTimezone(ctx context.Context, msg *models.Message, us
|
||||
return
|
||||
}
|
||||
h.saveTimezone(ctx, msg.Chat.ID, user, args)
|
||||
loc := h.loadLocation(args)
|
||||
now := time.Now().In(loc).Format(domain.TimeLayout)
|
||||
h.sendText(ctx, msg.Chat.ID, fmt.Sprintf("Timezone set to %s (current time: %s)", args, now))
|
||||
}
|
||||
|
||||
func (h *Handler) handleSetBreak(ctx context.Context, msg *models.Message, user *domain.User) {
|
||||
@@ -489,6 +499,7 @@ func (h *Handler) handleSetBreak(ctx context.Context, msg *models.Message, user
|
||||
return
|
||||
}
|
||||
h.saveBreakThreshold(ctx, msg.Chat.ID, user, mins)
|
||||
h.sendText(ctx, msg.Chat.ID, fmt.Sprintf("Break threshold set to %d minutes.", mins))
|
||||
}
|
||||
|
||||
func (h *Handler) handleSetUsername(ctx context.Context, msg *models.Message, user *domain.User) {
|
||||
@@ -499,6 +510,7 @@ func (h *Handler) handleSetUsername(ctx context.Context, msg *models.Message, us
|
||||
return
|
||||
}
|
||||
h.saveUsername(ctx, msg.Chat.ID, user, name)
|
||||
h.sendText(ctx, msg.Chat.ID, fmt.Sprintf("Username set to: %s", name))
|
||||
}
|
||||
|
||||
func (h *Handler) handleSetReportTime(ctx context.Context, msg *models.Message, user *domain.User) {
|
||||
@@ -515,7 +527,9 @@ func (h *Handler) handleSetReportTime(ctx context.Context, msg *models.Message,
|
||||
}
|
||||
if err := h.validateAndSaveReportTime(ctx, msg.Chat.ID, user, args); err != nil {
|
||||
h.sendText(ctx, msg.Chat.ID, err.Error())
|
||||
return
|
||||
}
|
||||
h.sendText(ctx, msg.Chat.ID, fmt.Sprintf("Report time set to %s", args))
|
||||
}
|
||||
|
||||
func (h *Handler) handleSetAccent(ctx context.Context, msg *models.Message, user *domain.User) {
|
||||
|
||||
Reference in New Issue
Block a user