]> khamidou — GitHub mirrors - prguy.git/commitdiff
gitignore
authorKarim Hamidou <karim@khamidou.com>
Wed, 26 Jun 2024 04:19:20 +0000 (21:19 -0700)
committerKarim Hamidou <karim@khamidou.com>
Wed, 26 Jun 2024 04:19:20 +0000 (21:19 -0700)
.gitignore
cmd/prguy/main.go

index 6f6f5e6adc1d36f3413df4a147c6054caedd796a..84f59c190469cad05a0ed39cc9ce3f5c69c54b5d 100644 (file)
@@ -20,3 +20,6 @@
 # Go workspace file
 go.work
 go.work.sum
+
+*.swp
+*.swo
index 6b1055a73559b3dd6f322a7bf8af40217ad8d4fa..272b049bab7a4e9b7580e2f6a98fd40f1f1cc271 100644 (file)
@@ -32,7 +32,7 @@ func errorOut(title string, message string) {
 
 func setupMenu(ctx context.Context, cancel context.CancelFunc) {
        systray.SetTemplateIcon([]byte("🕴️"), []byte("🕴️"))
-       systray.SetTitle("PR Guy")
+       systray.SetTitle("🕴️")
        config := Config{}
 
        go func() {
@@ -57,27 +57,56 @@ func setupMenu(ctx context.Context, cancel context.CancelFunc) {
                        }
                } else {
                        cfg := Config{}
+            var channels []chan struct{}
+            var channelsMap = make(map[chan struct{}]pullRequest)
+
                        cfg.load()
             systray.ResetMenu()
 
-                       prs, err := listUserPRs(cfg.OAuthToken)
+                       myPRs, otherPRs, err := listUserPRs(cfg.OAuthToken)
                        if err != nil {
                                errorOut("Error fetching PRs", err.Error())
                        }
 
-            var channels []chan struct{}
-                       for _, pr := range prs {
-                var pr_status string
-                if pr.mergeable {
-                    pr_status = "✅"
-                } else {
-                    pr_status = "❌"
+            if len(myPRs) == 0 {
+                systray.AddMenuItem("No PRs out from you, let's get after it!", "")
+            } else {
+                for _, pr := range myPRs {
+                    var pr_status string
+                    if pr.mergeable {
+                        pr_status = "✅"
+                    } else {
+                        pr_status = "❌"
+                    }
+
+                    title := fmt.Sprintf("%-*s %s", 50, pr.title, pr_status)
+                    channel := systray.AddMenuItem(title, "")
+                    channels = append(channels, channel.ClickedCh)
+                    channelsMap[channel.ClickedCh] = pr
                 }
+            }
 
-                title := fmt.Sprintf("%-*s %s", 50, pr.title, pr_status)
-                channel := systray.AddMenuItem(title, "")
-                channels = append(channels, channel.ClickedCh)
-                       }
+            systray.AddSeparator()
+
+            if len(myPRs) != 0 && len(otherPRs) == 0 {
+                systray.AddMenuItem("No PRs from others, no news is good news.", "")
+            } else if len(otherPRs) != 0 {
+                for _, pr := range myPRs {
+                    var pr_status string
+                    if pr.mergeable {
+                        pr_status = "✅"
+                    } else {
+                        pr_status = "❌"
+                    }
+
+                    title := fmt.Sprintf("%-*s %s", 50, pr.title, pr_status)
+                    channel := systray.AddMenuItem(title, "")
+                    channels = append(channels, channel.ClickedCh)
+                    channelsMap[channel.ClickedCh] = pr
+                }
+            }
+
+            systray.AddSeparator()
 
                        mQuitOrig := systray.AddMenuItem("Quit", "Quit the app")
             channels = append(channels, mQuitOrig.ClickedCh)
@@ -94,7 +123,7 @@ func setupMenu(ctx context.Context, cancel context.CancelFunc) {
                                        systray.Quit()
                 } else {
                     // open the PR
-                    pr := prs[i]
+                    pr := channelsMap[channels[i]]
                     open.Run(pr.url)
                 }
                        }