ref: 130a67e3ea3b577055f9779f90a5d10fb8f1d85e
parent: 6953f303b3c111e7cc180f421fd00b99dd781114
author: penny <penny@limitedideas.org>
date: Fri Oct 17 14:55:16 EDT 2025
convert more of main to uain to use API dispatcher
--- a/main.go
+++ b/main.go
@@ -384,34 +384,46 @@
savePostImages(postItem, hc.preferences.Save_Location)
return
case "rt":
- rtStatus, err := client.Reblog(context.Background(), postItem.ID)
- if err != nil {- fmt.Println(err)
+ rtfunc := func() {+ rtStatus, err := client.Reblog(context.Background(), postItem.ID)
+ if err != nil {+ fmt.Println(err)
+ return
+ }
+ *recentpost = rtStatus
+ hc.printAndIncrement(hc.ctxref, rtStatus)
return
}
- *recentpost = rtStatus
- hc.printAndIncrement(hc.ctxref, rtStatus)
+ hc.dispatchAnon(rtfunc).Wait()
return
case "parent":
- if postItem.InReplyToID == nil {- fmt.Printf("%v doesn't have a parent\n", index)+ parentfunc := func() {+ if postItem.InReplyToID == nil {+ fmt.Printf("%v doesn't have a parent\n", index)+ return
+ }
+ parentStatus, _ := client.GetStatus(context.Background(), mastodon.ID(postItem.InReplyToID.(string)))
+ hc.printAndIncrement(hc.ctxref, parentStatus)
return
}
- parentStatus, _ := client.GetStatus(context.Background(), mastodon.ID(postItem.InReplyToID.(string)))
- hc.printAndIncrement(hc.ctxref, parentStatus)
+ hc.dispatchAnon(parentfunc).Wait()
return
case "children":
- context, err := client.GetStatusContext(context.Background(), postItem.ID)
- if err != nil {- fmt.Println(err)
+ childfunc := func() {+ context, err := client.GetStatusContext(context.Background(), postItem.ID)
+ if err != nil {+ fmt.Println(err)
+ return
+ }
+ if len(context.Descendants) == 0 {+ fmt.Printf("\"%s\" has no children\n", index)+ }
+ for post := range context.Descendants {+ hc.printAndIncrement(hc.ctxref, context.Descendants[post])
+ }
return
}
- if len(context.Descendants) == 0 {- fmt.Printf("\"%s\" has no children\n", index)- }
- for post := range context.Descendants {- hc.printAndIncrement(hc.ctxref, context.Descendants[post])
- }
+ hc.dispatchAnon(childfunc).Wait()
return
case "edit":
if content == "" || content == " " {@@ -439,11 +451,15 @@
id := mastodon.ID(postItem.InReplyToID.(string))
toot.InReplyToID = id
}
- _, err = client.UpdateStatus(context.Background(), toot, postItem.ID)
- if err != nil {- fmt.Println(err)
- return
+ editfunc := func() {+ _, err = client.UpdateStatus(context.Background(), toot, postItem.ID)
+ if err != nil {+ fmt.Println(err)
+ return
+ }
}
+ hc.dispatchAnon(editfunc).Wait()
+ return
case "thread":
hc.pause(true)
hc.page = &Page{disablereverse: true}--
⑨