Implemented mark all as read, fixes #22

pull/34/head
マリウス 2 years ago
parent 76a54af56e
commit b3fcef96f8
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F

@ -91,18 +91,20 @@ func (cfg *Config) LoadDefaults() (error) {
cfg.Shortcuts[strconv.FormatInt(int64(tcell.KeyCtrlL), 10)] = "focus-articles"
cfg.Shortcuts[strconv.FormatInt(int64(tcell.KeyCtrlK), 10)] = "focus-articles"
cfg.Shortcuts[strconv.FormatInt(int64(tcell.KeyCtrlJ), 10)] = "focus-preview"
cfg.Shortcuts[strconv.FormatInt(int64('n'), 10)] = "article-new"
cfg.Shortcuts[strconv.FormatInt(int64('r'), 10)] = "article-reply"
cfg.Shortcuts[strconv.FormatInt(int64('h'), 10)] = "additional-key-left"
cfg.Shortcuts[strconv.FormatInt(int64('j'), 10)] = "additional-key-down"
cfg.Shortcuts[strconv.FormatInt(int64('k'), 10)] = "additional-key-up"
cfg.Shortcuts[strconv.FormatInt(int64('l'), 10)] = "additional-key-right"
cfg.Shortcuts[strconv.FormatInt(int64('n'), 10)] = "article-new"
cfg.Shortcuts[strconv.FormatInt(int64('r'), 10)] = "article-reply"
cfg.Shortcuts[strconv.FormatInt(int64(tcell.KeyCtrlA), 10)] = "article-mark-all-read"
cfg.Shortcuts[strconv.FormatInt(int64('g'), 10)] = "additional-key-home"
cfg.Shortcuts[strconv.FormatInt(int64('G'), 10)] = "additional-key-end"
cfg.Shortcuts[strconv.FormatInt(int64('h'), 10)] = "additional-key-left"
cfg.Shortcuts[strconv.FormatInt(int64('j'), 10)] = "additional-key-down"
cfg.Shortcuts[strconv.FormatInt(int64('k'), 10)] = "additional-key-up"
cfg.Shortcuts[strconv.FormatInt(int64('l'), 10)] = "additional-key-right"
cfg.Shortcuts[strconv.FormatInt(int64(tcell.KeyF8), 10)] = "play"
cfg.Shortcuts[strconv.FormatInt(int64('g'), 10)] = "additional-key-home"
cfg.Shortcuts[strconv.FormatInt(int64('G'), 10)] = "additional-key-end"
cfg.Shortcuts[strconv.FormatInt(int64(tcell.KeyF8), 10)] = "play"
}
return cfg.Persist()
}

@ -323,6 +323,9 @@ func (mainscreen *Mainscreen) HandleInput(event *tcell.EventKey) (*tcell.EventKe
case "article-reply":
mainscreen.replyToArticle(mainscreen.ArticlesList[mainscreen.CurrentArticleSelected])
return nil
case "article-mark-all-read":
mainscreen.markAllAsRead()
return nil
case "additional-key-down":
mainscreen.T.App.QueueEvent(tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone))
return nil
@ -406,6 +409,12 @@ func(mainscreen *Mainscreen) markAsRead(index int, article *models.Article) {
mainscreen.T.Cache.StoreArticle(article)
}
func(mainscreen *Mainscreen) markAllAsRead() {
for i := 0; i < len(mainscreen.ArticlesList); i++ {
mainscreen.markAsRead(i, mainscreen.ArticlesList[i])
}
}
func(mainscreen *Mainscreen) submitNewArticle(group string) {
newArticle := models.NewArticle()

Loading…
Cancel
Save