From 6be80b42b67efa696f6ec53cd0b87aa740256e6c Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Mon, 15 Dec 2025 17:13:12 +0100 Subject: [PATCH] chore: remove unused methods --- internal/ui/chat/chat.go | 18 ------------------ internal/ui/list/filterable.go | 10 ---------- internal/ui/list/list.go | 31 ------------------------------- 3 files changed, 59 deletions(-) diff --git a/internal/ui/chat/chat.go b/internal/ui/chat/chat.go index 30220942f16c680e4c18babfd2492778929fe2c9..0c615e37c0c1a4cb8c5634cb8fba1729ef761134 100644 --- a/internal/ui/chat/chat.go +++ b/internal/ui/chat/chat.go @@ -77,12 +77,6 @@ func (m *Chat) Len() int { return m.list.Len() } -// PrependItems prepends new items to the chat list. -func (m *Chat) PrependItems(items ...list.Item) { - m.list.PrependItems(items...) - m.list.ScrollToIndex(0) -} - // SetMessages sets the chat messages to the provided list of message items. func (m *Chat) SetMessages(msgs ...MessageItem) { items := make([]list.Item, len(msgs)) @@ -108,18 +102,6 @@ func (m *Chat) AppendItems(items ...list.Item) { m.list.ScrollToIndex(m.list.Len() - 1) } -// UpdateMessage updates an existing message by ID. Returns true if the message -// was found and updated. -func (m *Chat) UpdateMessage(id string, msg MessageItem) bool { - for i := 0; i < m.list.Len(); i++ { - item := m.list.GetItemAt(i) - if identifiable, ok := item.(Identifiable); ok && identifiable.ID() == id { - return m.list.UpdateItemAt(i, msg) - } - } - return false -} - // GetMessage returns the message with the given ID. Returns nil if not found. func (m *Chat) GetMessage(id string) MessageItem { for i := 0; i < m.list.Len(); i++ { diff --git a/internal/ui/list/filterable.go b/internal/ui/list/filterable.go index c45db41da2cc6be8bd61fba57818e5a7d902f5cd..f128f984451b0a8cf3ab38f48836c9a5cbeccbb4 100644 --- a/internal/ui/list/filterable.go +++ b/internal/ui/list/filterable.go @@ -55,16 +55,6 @@ func (f *FilterableList) AppendItems(items ...FilterableItem) { f.List.SetItems(itms...) } -// PrependItems prepends items to the list and updates the filtered items. -func (f *FilterableList) PrependItems(items ...FilterableItem) { - f.items = append(items, f.items...) - itms := make([]Item, len(f.items)) - for i, item := range f.items { - itms[i] = item - } - f.List.SetItems(itms...) -} - // SetFilter sets the filter query and updates the list items. func (f *FilterableList) SetFilter(q string) { f.query = q diff --git a/internal/ui/list/list.go b/internal/ui/list/list.go index d8e27eb3d5762658cca646ece6f41ea680b8d276..f16f5d14ca0a18b34df5f9038c19c63e63877138 100644 --- a/internal/ui/list/list.go +++ b/internal/ui/list/list.go @@ -375,26 +375,6 @@ func (l *List) Render() string { return strings.Join(lines, "\n") } -// PrependItems prepends items to the list. -func (l *List) PrependItems(items ...Item) { - l.items = append(items, l.items...) - - // Shift cache - newCache := make(map[int]renderedItem) - for idx, val := range l.renderedItems { - newCache[idx+len(items)] = val - } - l.renderedItems = newCache - - // Keep view position relative to the content that was visible - l.offsetIdx += len(items) - - // Update selection index if valid - if l.selectedIdx != -1 { - l.selectedIdx += len(items) - } -} - // SetItems sets the items in the list. func (l *List) SetItems(items ...Item) { l.setItems(true, items...) @@ -417,17 +397,6 @@ func (l *List) AppendItems(items ...Item) { l.items = append(l.items, items...) } -// UpdateItemAt updates the item at the given index and invalidates its cache. -// Returns true if the index was valid and the item was updated. -func (l *List) UpdateItemAt(idx int, item Item) bool { - if idx < 0 || idx >= len(l.items) { - return false - } - l.items[idx] = item - l.invalidateItem(idx) - return true -} - // GetItemAt returns the item at the given index. Returns nil if the index is // out of bounds. func (l *List) GetItemAt(idx int) Item {