app

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	API    *api.Client
	Store  *store.Store
	Config config.Config
}

App is the core engine that orchestrates the API client and local store.

func New

func New(apiClient *api.Client, db *store.Store, cfg config.Config) *App

New creates a new App instance.

func (*App) AddActiveBook

func (a *App) AddActiveBook(bookID int) error

AddActiveBook appends a book to the active list if missing.

func (*App) ChangeStatus

func (a *App) ChangeStatus(ctx context.Context, bookID int, status model.Status) error

ChangeStatus changes a book's status. If bookID is 0, uses the single active book. If the book has no user_book entry yet, creates one via InsertUserBook.

func (*App) GetActiveBook

func (a *App) GetActiveBook() (*model.UserBook, error)

GetActiveBook returns the active UserBook from cache.

func (*App) GetActiveBookID

func (a *App) GetActiveBookID() (int, error)

GetActiveBookID returns the active book ID from local state. When multiple active books exist, callers must pass --book explicitly.

func (*App) GetActiveBookIDs

func (a *App) GetActiveBookIDs() ([]int, error)

GetActiveBookIDs returns the list of active reading book IDs.

func (*App) GetActiveBooks

func (a *App) GetActiveBooks() ([]model.UserBook, error)

GetActiveBooks returns all active books found in cache.

func (*App) GetHeatmap

func (a *App) GetHeatmap(weeks int) ([]model.DayActivity, error)

GetHeatmap returns daily activity data for the given number of weeks.

func (*App) GetStreak

func (a *App) GetStreak() (*model.StreakInfo, error)

GetStreak computes the current, longest, and total reading streak from session data.

func (*App) ListBooks

func (a *App) ListBooks(ctx context.Context, status model.Status, refresh bool) ([]model.UserBook, error)

ListBooks returns user books for the given status. Serves from cache by default; if refresh is true, fetches from API first.

func (*App) RemoveActiveBook

func (a *App) RemoveActiveBook(bookID int) error

RemoveActiveBook removes a book from the active list.

func (*App) ResolveBookID

func (a *App) ResolveBookID(bookID int) (int, error)

ResolveBookID returns the given bookID if > 0, otherwise the active book ID.

func (*App) SearchBooks

func (a *App) SearchBooks(ctx context.Context, query string, limit int, mode model.SearchMode) ([]model.SearchResult, error)

SearchBooks queries the Hardcover API for books matching the query and mode. Search always hits the API (not cache) since it uses Typesense.

func (*App) SetActiveBook

func (a *App) SetActiveBook(bookID int) error

SetActiveBook adds a book to the active list by book ID.

func (*App) SyncAll

func (a *App) SyncAll(ctx context.Context) error

SyncAll refreshes all tracked status lists into the local cache.

func (*App) TimerList

func (a *App) TimerList(limit int) ([]model.ReadingSession, error)

TimerList returns the most recent reading sessions.

func (*App) TimerStart

func (a *App) TimerStart(bookID int) error

TimerStart begins a new reading session for the given book. Returns an error if a timer is already running.

func (*App) TimerStats

func (a *App) TimerStats(weeks int) (model.WeeklyStats, error)

TimerStats returns weekly reading stats for the given number of weeks back from now.

func (*App) TimerStatus

func (a *App) TimerStatus() (*model.TimerState, error)

TimerStatus returns the current timer state, or nil if no timer is running.

func (*App) TimerStop

func (a *App) TimerStop() (*model.ReadingSession, error)

TimerStop ends the current timer, records the session, and returns it. Returns an error if no timer is running.

func (*App) UpdateProgress

func (a *App) UpdateProgress(ctx context.Context, bookID int, pageUpdate model.PageUpdate) (int, error)

UpdateProgress updates the reading progress for a book. If bookID is 0, uses the single active book.

func (*App) ValidateToken

func (a *App) ValidateToken(ctx context.Context) (int, string, error)

ValidateToken calls GetMe to verify the token works and caches the user ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL