Skip to content

Commit e79309b

Browse files
committed
test
1 parent afccf1b commit e79309b

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed

ui/components/dashboard/dashboard.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/charmbracelet/bubbles/key"
88
tea "github.com/charmbracelet/bubbletea"
99
"github.com/charmbracelet/lipgloss"
10+
"github.com/charmbracelet/log"
1011

1112
"github.com/dlvhdr/gh-dash/config"
1213
"github.com/dlvhdr/gh-dash/ui/common"
@@ -75,10 +76,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
7576
cmd = fetchSectionsCmds
7677

7778
case section.SectionDataFetchedMsg:
78-
boardId := 0
79-
cards := m.boards[boardId].cards
79+
card := m.getCardById(msg.Id)
8080
if msg.Type == string(config.PRsView) {
81-
cards[msg.Id].SetPrs(prssection.SectionPullRequestsFetchedMsg{
81+
card.SetPrs(prssection.SectionPullRequestsFetchedMsg{
8282
Prs: msg.Prs,
8383
TotalCount: msg.TotalCount,
8484
PageInfo: msg.PageInfo,
@@ -115,13 +115,15 @@ func (m *Model) UpdateProgramContext(ctx *context.ProgramContext) {
115115
func (m *Model) fetchAllDashboards() tea.Cmd {
116116
var cmds []tea.Cmd
117117

118+
sectionsSoFar := 0
118119
for i := 0; i < len(m.ctx.Config.Dashboards); i++ {
119120
var cards []*sectioncard.Model
120-
for j := 0; j < len(m.ctx.Config.Dashboards[i].Sections); j++ {
121+
numSections := len(m.ctx.Config.Dashboards[i].Sections)
122+
for j := 0; j < numSections; j++ {
121123
sectionConfig := m.ctx.Config.Dashboards[i].Sections[j]
122124
sectionModel := section.Model{
123125
BaseModel: section.BaseModel{
124-
Id: j,
126+
Id: sectionsSoFar + j,
125127
Ctx: m.ctx,
126128
Type: "prs",
127129
Config: sectionConfig,
@@ -165,6 +167,7 @@ func (m *Model) fetchAllDashboards() tea.Cmd {
165167
m.boards = append(m.boards, board{
166168
cards: cards,
167169
})
170+
sectionsSoFar += numSections
168171
}
169172

170173
return tea.Batch(cmds...)
@@ -205,3 +208,20 @@ func (m *Model) nextBoard() {
205208
len(m.boards),
206209
)
207210
}
211+
212+
func (m *Model) getCardById(id int) (card *sectioncard.Model) {
213+
i := 0
214+
cardsSoFar := 0
215+
for i < len(m.boards) {
216+
numCards := len(m.boards[i].cards)
217+
if cardsSoFar+numCards <= id {
218+
i++
219+
cardsSoFar += numCards
220+
continue
221+
}
222+
break
223+
}
224+
225+
log.Debug("getCardById", "i", i, "id", id, "cardsSoFar", cardsSoFar)
226+
return m.boards[i].cards[id-cardsSoFar]
227+
}

ui/components/sectionsview/sectionsview.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
tea "github.com/charmbracelet/bubbletea"
1111
log "github.com/charmbracelet/log"
1212
"github.com/cli/go-gh/pkg/browser"
13+
1314
"github.com/dlvhdr/gh-dash/config"
1415
"github.com/dlvhdr/gh-dash/data"
1516
"github.com/dlvhdr/gh-dash/ui/common"
@@ -131,12 +132,10 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
131132
}
132133

133134
case common.ConfigReadMsg:
134-
log.Debug("config read")
135135
fetchSectionsCmds := m.FetchAllViewSections(true)
136136
cmd = fetchSectionsCmds
137137

138138
case section.SectionMsg:
139-
log.Debug("SectionMsg", "id", msg.Id, "type", msg.Type)
140139
cmd = m.updateRelevantSection(msg)
141140

142141
}
@@ -194,7 +193,6 @@ func (m *Model) FetchAllViewSections(force bool) tea.Cmd {
194193
return nil
195194
}
196195

197-
log.Debug("Fetching all view sections", "view", m.ctx.View)
198196
if m.ctx.View == config.PRsView {
199197
sections, cmd = prssection.FetchAllSections(*m.ctx)
200198
} else if m.ctx.View == config.IssuesView {

ui/components/table/table.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"time"
55

66
"github.com/charmbracelet/lipgloss"
7-
"github.com/charmbracelet/log"
87

98
"github.com/dlvhdr/gh-dash/ui/common"
109
"github.com/dlvhdr/gh-dash/ui/components/listviewport"
@@ -128,7 +127,6 @@ func (m *Model) LastItem() int {
128127
}
129128

130129
func (m *Model) SyncViewPortContent() {
131-
log.Debug("SyncViewPortContent")
132130
headerColumns := m.renderHeaderColumns()
133131
renderedRows := make([]string, 0, len(m.Rows))
134132
for i := range m.Rows {
@@ -237,7 +235,6 @@ func (m *Model) renderBody() string {
237235
func (m *Model) renderRow(rowId int, headerColumns []string) string {
238236
var style lipgloss.Style
239237

240-
log.Debug("renderRow", "numItems", len(m.Rows), "isActive", m.IsActive)
241238
if m.IsActive && m.rowsViewport.GetCurrItem() == rowId {
242239
style = m.ctx.Styles.Table.SelectedCellStyle
243240
} else if m.CellStyle != nil {

ui/context/styles.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package context
33
import (
44
bbHelp "github.com/charmbracelet/bubbles/help"
55
"github.com/charmbracelet/lipgloss"
6-
"github.com/charmbracelet/log"
76

87
"github.com/dlvhdr/gh-dash/ui/common"
98
"github.com/dlvhdr/gh-dash/ui/theme"
@@ -293,7 +292,5 @@ func InitStyles(theme theme.Theme) Styles {
293292
s.Card.Content = lipgloss.NewStyle().
294293
Background(lipgloss.Color("#1f2336"))
295294

296-
log.Debug("border", "border", s.Card.Root.GetBorderStyle())
297-
298295
return s
299296
}

ui/ui.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,6 @@ func (m *Model) onWindowSizeChanged(msg tea.WindowSizeMsg) {
350350
m.ctx.ScreenWidth = msg.Width
351351
m.ctx.ScreenHeight = msg.Height
352352
m.ctx.MainContentHeight = msg.Height - common.TabsHeight - common.FooterHeight
353-
log.Debug(
354-
"Window size changed",
355-
"width",
356-
msg.Width,
357-
"height",
358-
msg.Height,
359-
"MainContentHeight",
360-
m.ctx.MainContentHeight,
361-
)
362353
}
363354

364355
func (m *Model) syncProgramContext() {

0 commit comments

Comments
 (0)