Documentation
¶
Index ¶
- type App
- func (a *App) AddActiveBook(bookID int) error
- func (a *App) ChangeStatus(ctx context.Context, bookID int, status model.Status) error
- func (a *App) GetActiveBook() (*model.UserBook, error)
- func (a *App) GetActiveBookID() (int, error)
- func (a *App) GetActiveBookIDs() ([]int, error)
- func (a *App) GetActiveBooks() ([]model.UserBook, error)
- func (a *App) GetHeatmap(weeks int) ([]model.DayActivity, error)
- func (a *App) GetStreak() (*model.StreakInfo, error)
- func (a *App) ListBooks(ctx context.Context, status model.Status, refresh bool) ([]model.UserBook, error)
- func (a *App) RemoveActiveBook(bookID int) error
- func (a *App) ResolveBookID(bookID int) (int, error)
- func (a *App) SearchBooks(ctx context.Context, query string, limit int, mode model.SearchMode) ([]model.SearchResult, error)
- func (a *App) SetActiveBook(bookID int) error
- func (a *App) SyncAll(ctx context.Context) error
- func (a *App) TimerList(limit int) ([]model.ReadingSession, error)
- func (a *App) TimerStart(bookID int) error
- func (a *App) TimerStats(weeks int) (model.WeeklyStats, error)
- func (a *App) TimerStatus() (*model.TimerState, error)
- func (a *App) TimerStop() (*model.ReadingSession, error)
- func (a *App) UpdateProgress(ctx context.Context, bookID int, pageUpdate model.PageUpdate) (int, error)
- func (a *App) ValidateToken(ctx context.Context) (int, string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
App is the core engine that orchestrates the API client and local store.
func (*App) AddActiveBook ¶
AddActiveBook appends a book to the active list if missing.
func (*App) ChangeStatus ¶
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 ¶
GetActiveBook returns the active UserBook from cache.
func (*App) GetActiveBookID ¶
GetActiveBookID returns the active book ID from local state. When multiple active books exist, callers must pass --book explicitly.
func (*App) GetActiveBookIDs ¶
GetActiveBookIDs returns the list of active reading book IDs.
func (*App) GetActiveBooks ¶
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 ¶
RemoveActiveBook removes a book from the active list.
func (*App) ResolveBookID ¶
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 ¶
SetActiveBook adds a book to the active list by book ID.
func (*App) TimerList ¶
func (a *App) TimerList(limit int) ([]model.ReadingSession, error)
TimerList returns the most recent reading sessions.
func (*App) TimerStart ¶
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.