From 15494e99b4ec45ec2e990f14da3c189f3429fc26 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 25 Nov 2020 22:08:24 -0500 Subject: [PATCH] Also disable news if we're in local-only mode --- ui/stash.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/stash.go b/ui/stash.go index a58fbd6..bc0775b 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -107,7 +107,7 @@ type stashModel struct { } func (m stashModel) localOnly() bool { - return m.general.cfg.DocumentTypes == LocalDocument + return m.general.cfg.DocumentTypes^LocalDocument == 0 } func (m stashModel) stashedOnly() bool { @@ -119,6 +119,12 @@ func (m stashModel) loadingDone() bool { return m.loaded == m.general.cfg.DocumentTypes } +// Returns whether or not we're online. That is, when "local-only" mode is +// disabled and we've authenticated successfully. +func (m stashModel) online() bool { + return !m.localOnly() && m.general.authStatus == authOK +} + func (m *stashModel) setSize(width, height int) { m.general.width = width m.general.height = height @@ -613,7 +619,7 @@ func (m *stashModel) handleDocumentBrowsing(msg tea.Msg) tea.Cmd { // Show news case "n": - if m.general.authStatus == authFailed { + if !m.online() { // If we're offline disable the news section return nil }