Documentation
¶
Index ¶
- Variables
- func DeleteItem(sender tab.Tab, key string) tea.Cmd
- func DownloadItem(key string, index int) tea.Cmd
- func NewItem(sender tab.Tab, editing bool, fields []string) tea.Cmd
- type Backend
- func (b Backend) Close() error
- func (b Backend) DownloadItem(key string, index int) tea.Cmd
- func (b Backend) FetchAllArticles(_ string) tea.Cmd
- func (b Backend) FetchArticles(feedName string) tea.Cmd
- func (b Backend) FetchCategories() tea.Cmd
- func (b Backend) FetchDownloadedArticles(_ string) tea.Cmd
- func (b Backend) FetchFeeds(catName string) tea.Cmd
- func (b Backend) RemoveDownload(key string) error
- func (b *Backend) SetOfflineMode(mode bool)
- type Cache
- func (c *Cache) AddToDownloaded(url string, index int) error
- func (c *Cache) GetArticles(url string) (SortableArticles, error)
- func (c *Cache) GetArticlesBulk(urls []string) SortableArticles
- func (c *Cache) GetDownloaded() SortableArticles
- func (c *Cache) Load() error
- func (c *Cache) RemoveFromDownloaded(index int) error
- func (c *Cache) Save() error
- func (c *Cache) SetOfflineMode(mode bool)
- type DeleteItemMessage
- type DownloadItemMessage
- type Entry
- type FetchArticleSuccessMessage
- type FetchErrorMessage
- type FetchSuccessMessage
- type NewItemMessage
- type SortableArticles
Constants ¶
This section is empty.
Variables ¶
var DefaultCacheDuration = 24 * time.Hour
DefaultCacheDuration is the default duration for which an item is cached
var DefaultCacheSize = 100
DefaultCacheSize is the default size of the cache
var ErrOfflineMode = fmt.Errorf("offline mode")
ErrOfflineMode is returned when the backend is in offline mode
Functions ¶
func DeleteItem ¶
DeleteItem is a function to tell the main model that a new item needs to be removed from the list
func DownloadItem ¶ added in v1.1.0
DownloadItem is a function to tell the main model that a new item needs to be downloaded
Types ¶
type Backend ¶
Backend uses a local cache to get all the feeds and their articles
func (Backend) DownloadItem ¶ added in v1.1.0
DownloadItem returns a tea.Cmd which downloads an item
func (Backend) FetchAllArticles ¶ added in v1.0.2
FetchAllArticles returns a tea.Cmd which gets all the articles from the backend
func (Backend) FetchArticles ¶
FetchArticles returns a tea.Cmd which gets the articles from the backend via a string key
func (Backend) FetchCategories ¶
FetchCategories returns a tea.Cmd which gets the category list from the backend
func (Backend) FetchDownloadedArticles ¶ added in v1.1.0
FetchDownloaded returns a tea.Cmd which gets all the downloaded articles from the backend
func (Backend) FetchFeeds ¶
FetchFeeds returns a tea.Cmd which gets the feed list from the backend via a string key
func (Backend) RemoveDownload ¶ added in v1.2.0
RemoveDownload tries to remove a download from the backend
func (*Backend) SetOfflineMode ¶ added in v1.2.0
SetOfflineMode sets the offline mode of the backend
type Cache ¶
type Cache struct {
Content map[string]Entry `json:"content"`
Downloaded SortableArticles `json:"downloaded"`
// contains filtered or unexported fields
}
Cache handles the caching of feeds and storing downloaded articles
func (*Cache) AddToDownloaded ¶ added in v1.1.0
AddToDownloaded adds an item to the downloaded list
func (*Cache) GetArticles ¶ added in v1.2.0
func (c *Cache) GetArticles(url string) (SortableArticles, error)
GetArticles returns an article list using the cache if possible
func (*Cache) GetArticlesBulk ¶ added in v1.2.0
func (c *Cache) GetArticlesBulk(urls []string) SortableArticles
GetArticlesBulk returns a sorted list of articles from all the given urls, ignoring any errors
func (*Cache) GetDownloaded ¶ added in v1.1.0
func (c *Cache) GetDownloaded() SortableArticles
GetDownloaded returns a list of downloaded items
func (*Cache) RemoveFromDownloaded ¶ added in v1.2.0
RemoveFromDownloaded removes an item from the downloaded list
func (*Cache) SetOfflineMode ¶ added in v1.2.0
SetOfflineMode sets the offline mode
type DeleteItemMessage ¶
DeleteItemMessage is a message to tell the main model that a new item needs to be removed from the list
type DownloadItemMessage ¶ added in v1.1.0
DownloadItemMessage is a message to tell the main model that a new item needs to be downloaded
type Entry ¶ added in v1.2.0
type Entry struct {
Expire time.Time `json:"expire"`
Articles SortableArticles `json:"articles"`
}
Entry is a cache entry
type FetchArticleSuccessMessage ¶ added in v1.2.0
FetchArticleSuccessMessage is a message that is sent when the fetching of the articles was successful
type FetchErrorMessage ¶
FetchErrorMessage is a message that is sent when the fetching of the categories or feeds failed
type FetchSuccessMessage ¶
FetchSuccessMessage is a message that is sent when the fetching of the categories or feeds was successful
type NewItemMessage ¶
NewItemMessage is a message to tell the main model that a new item needs to be added to the list
type SortableArticles ¶ added in v1.2.0
SortableArticles is a sortable list of articles
func (SortableArticles) Len ¶ added in v1.2.0
func (sa SortableArticles) Len() int
Len returns the length of the item list, needed for sorting
func (SortableArticles) Less ¶ added in v1.2.0
func (sa SortableArticles) Less(a, b int) bool
Less returns true if the item at index i is less than the item at index j, needed for sorting
func (SortableArticles) Swap ¶ added in v1.2.0
func (sa SortableArticles) Swap(a, b int)
Swap swaps the items at index i and j, needed for sorting