all repos

smutok @ d588b2a

yet another tui rss reader (not abandoned, just paused development)
3 files changed, 20 insertions(+), 5 deletions(-)
fix(worker): start worker immediately
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2025-12-28 19:20:24 +0200
Change ID: vlumsmuzsvrltwxxrmwswxsmvzqlyuwv
Parent: 63bd597
M internal/freshrss/client.go

@@ -217,6 +217,10 @@ TagToRemove string

} func (g Client) EditTag(ctx context.Context, writeToken string, opts EditTag) error { + if len(opts.ItemID) == 0 { + return ErrInvalidRequest + } + body := url.Values{} body.Set("T", writeToken) setOption(&body, "a", opts.TagToAdd)

@@ -250,7 +254,11 @@ // Remove, StreamId to remove the subscription(s) from (generally a category)

Remove string } -func (g Client) SubscriptionEdit(ctx context.Context, token string, opts EditSubscription) (string, error) { +func (g Client) SubscriptionEdit( + ctx context.Context, + token string, + opts EditSubscription, +) (string, error) { if opts.Action == "" { return "", ErrInvalidRequest }

@@ -305,7 +313,12 @@ return g.handleResponse(req, resp)

} // postRequest makes POST requests with parameters passed as form. -func (g *Client) postRequest(ctx context.Context, endpoint string, body url.Values, resp any) error { +func (g *Client) postRequest( + ctx context.Context, + endpoint string, + body url.Values, + resp any, +) error { var reqBody io.Reader if body != nil { reqBody = strings.NewReader(body.Encode())
M internal/freshrss/worker.go

@@ -25,7 +25,6 @@ }

} func (w *Worker) Run(ctx context.Context) { - // TODO: get tick time from config ??? ticker := time.NewTicker(5 * time.Second) defer ticker.Stop()

@@ -34,7 +33,7 @@ for {

select { case <-ctx.Done(): return - case <-ticker.C: + default: if !w.isNetworkAvailable(ctx) { slog.Info("worker: no internet connection") continue

@@ -60,7 +59,9 @@ if err := w.pendingUnstar(ctx); err != nil {

slog.Error("worker: unread", "err", err) } }) + wg.Wait() + <-ticker.C } } }

@@ -97,6 +98,7 @@ return err

} if len(articleIDs) == 0 { + slog.Debug("worker: no pending actions", "action", action) return nil }
M internal/store/sqlite_pendin_actions.go

@@ -67,7 +67,7 @@ select article_id

from pending_actions where action = ? order by created_at desc - limit 10` + limit 20` rows, err := s.db.QueryContext(ctx, query, action.String()) if err != nil {