Skip to content

Commit

Permalink
we don`t need chats for batch mode in main
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Nov 25, 2023
1 parent 1749b0c commit 7b0abfd
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,27 +192,27 @@ func run(ctx context.Context, p Params) error {
}
}()

ctx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM)
defer stop()

done, finished := fakeProgress("Getting chats . . .", 0)
chats, err := cl.GetChats(ctx)
close(done)
<-finished
if err != nil {
return err
}
sort.Slice(chats, func(i, j int) bool {
return chats[i].GetTitle() < chats[j].GetTitle()
})
dlog.Printf("got %d chats", len(chats))

if p.List {
return waipu.List(ctx, os.Stdout, cl)
} else if len(p.Batch) > 0 {
return waipu.Batch(ctx, cl, []int64(p.Batch))
} else {
// run UI
ctx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM)
defer stop()

done, finished := fakeProgress("Getting chats . . .", 0)
chats, err := cl.GetChats(ctx)
close(done)
<-finished
if err != nil {
return err
}
sort.Slice(chats, func(i, j int) bool {
return chats[i].GetTitle() < chats[j].GetTitle()
})
dlog.Printf("got %d chats", len(chats))

tva := tui.New(ctx, cl)
if err := tva.Run(ctx, chats); err != nil {
return err
Expand Down

0 comments on commit 7b0abfd

Please sign in to comment.