Skip to content

Commit

Permalink
perf: use spinner for waiting (#1618)
Browse files Browse the repository at this point in the history
* perf: use spinner for waiting

* perf: change to dot spinner

---------

Co-authored-by: Eric <[email protected]>
  • Loading branch information
fit2bot and LeeEirc committed Jan 6, 2025
1 parent dff1239 commit 5f657b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/proxy/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ func (p *Parser) waitCommandConfirm() {
titleMsg := lang.T("Need ticket confirm to execute command, already send email to the reviewers")
reviewersMsg := fmt.Sprintf(lang.T("Ticket Reviewers: %s"), strings.Join(reviewers, ", "))
detailURLMsg := fmt.Sprintf(lang.T("Could copy website URL to notify reviewers: %s"), detailURL)
spinner := []string{". ", ".. ", "... "}
var tipString strings.Builder
tipString.WriteString(utils.CharNewLine)
tipString.WriteString(titleMsg)
Expand All @@ -624,6 +625,8 @@ func (p *Parser) waitCommandConfirm() {
tipString.WriteString(utils.CharNewLine)
tipString.WriteString(detailURLMsg)
tipString.WriteString(utils.CharNewLine)
tipString.WriteString(waitMsg)
tipString.WriteString(utils.CharNewLine)
p.srvOutputChan <- []byte(utils.WrapperString(tipString.String(), utils.Green))
for {
select {
Expand All @@ -633,7 +636,8 @@ func (p *Parser) waitCommandConfirm() {
return
default:
delayS := fmt.Sprintf("%ds", delay)
data := strings.Repeat("\x08", len(delayS)+len(waitMsg)) + waitMsg + delayS
currentSpinner := spinner[delay%len(spinner)]
data := strings.Repeat("\x08", len(delayS)+len(currentSpinner)) + currentSpinner + delayS
p.srvOutputChan <- []byte(data)
time.Sleep(time.Second)
delay += 1
Expand Down

0 comments on commit 5f657b0

Please sign in to comment.