Skip to content

Commit

Permalink
fix: only enrich non-done notifications (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
nobe4 authored Jul 18, 2024
1 parent 85fd892 commit 839427a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
17 changes: 8 additions & 9 deletions internal/gh/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,18 @@ func (c *Client) paginate() (notifications.Notifications, error) {
return list, nil
}

func (c *Client) Notifications() (notifications.Notifications, error) {
list, err := c.paginate()
if err != nil {
return nil, err
}

for i, n := range list {
func (c *Client) Enrich(ns notifications.Notifications) (notifications.Notifications, error) {
for i, n := range ns {
if err := c.enrichNotification(n); err != nil {
return nil, err
}

list[i] = n
ns[i] = n
}

return list, nil
return ns, nil
}

func (c *Client) Notifications() (notifications.Notifications, error) {
return c.paginate()
}
5 changes: 4 additions & 1 deletion internal/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ func (m *Manager) Load() error {

m.Notifications = allNotifications.Uniq()

return nil
m.Notifications, err = m.client.Enrich(m.Notifications)

return err
}

func (m *Manager) shouldRefresh(expired bool) bool {
Expand Down Expand Up @@ -131,6 +133,7 @@ func (m *Manager) Apply(noop bool) error {
slog.Debug("apply rule", "name", rule.Name, "count", len(selectedIds))

for _, notification := range m.Notifications.FilterFromIds(selectedIds) {
// TODO: add --force flag to ignore this
if notification.Meta.Done {
continue
}
Expand Down

0 comments on commit 839427a

Please sign in to comment.