Skip to content

Commit

Permalink
minor clean code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
zMoooooritz committed Aug 3, 2024
1 parent aa71997 commit ab12a46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func main() {

p := tea.NewProgram(tui.InitialModel(configuration),
tea.WithAltScreen(),
// tea.WithMouseCellMotion(),
)
if _, err := p.Run(); err != nil {
fmt.Printf("There's been an error: %v", err)
Expand Down
15 changes: 5 additions & 10 deletions pkg/tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const (
)

var (
news tagesschau.News
imageSpec = tagesschau.ImageSpec{Size: tagesschau.SMALL, Ratio: tagesschau.RECT}
news tagesschau.News
)

type Model struct {
Expand Down Expand Up @@ -151,8 +150,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

for i, viewer := range m.viewers {
updateViewer, cmd := viewer.Update(msg)
m.viewers[i] = updateViewer
updatedViewer, cmd := viewer.Update(msg)
m.viewers[i] = updatedViewer
cmds = append(cmds, cmd)
}

Expand Down Expand Up @@ -180,6 +179,7 @@ func (m Model) activeViewer() Viewer {
}

func (m *Model) loadThumbnails() {
imageSpec := tagesschau.ImageSpec{Size: tagesschau.SMALL, Ratio: tagesschau.RECT}
for _, a := range news.NationalNews {
_ = m.imageCache.LoadImage(a.ID, tagesschau.GetImageURL(a.ImageData.ImageVariants, imageSpec))
}
Expand Down Expand Up @@ -249,12 +249,7 @@ func (m *Model) updateSizes(width, height int) {

m.selector.SetDims(m.width/3, m.height-m.helper.Height()-5)

isViewerFullscreen := false
for _, viewer := range m.viewers {
if viewer.IsFullScreen() {
isViewerFullscreen = true
}
}
isViewerFullscreen := m.activeViewer().IsFullScreen()
for _, viewer := range m.viewers {
if isViewerFullscreen {
viewer.SetDims(m.width, m.height-m.helper.Height())
Expand Down

0 comments on commit ab12a46

Please sign in to comment.