Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: use spinner for waiting #1618

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/proxy/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,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 @@ -594,6 +595,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 @@ -603,7 +606,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
Loading