on main help sign in
chore(chat): rename funcs
b0dd983Kujtim Hoxha
internal/ui/model/chat.go+8−8
@@ -169,30 +169,30 @@ func (m *Chat) Blur() {
169 m.list.Blur()
169 m.list.Blur()
170}
170}
171
171
172−// ScrollToTop scrolls the chat view to the top and returns a command to restart
172+// ScrollToTopAndAnimate scrolls the chat view to the top and returns a command to restart
173// any paused animations that are now visible.
173// any paused animations that are now visible.
174−func (m *Chat) ScrollToTop() tea.Cmd {
174+func (m *Chat) ScrollToTopAndAnimate() tea.Cmd {
175 m.list.ScrollToTop()
175 m.list.ScrollToTop()
176 return m.RestartPausedVisibleAnimations()
176 return m.RestartPausedVisibleAnimations()
177}
177}
178
178
179−// ScrollToBottom scrolls the chat view to the bottom and returns a command to
179+// ScrollToBottomAndAnimate scrolls the chat view to the bottom and returns a command to
180// restart any paused animations that are now visible.
180// restart any paused animations that are now visible.
181−func (m *Chat) ScrollToBottom() tea.Cmd {
181+func (m *Chat) ScrollToBottomAndAnimate() tea.Cmd {
182 m.list.ScrollToBottom()
182 m.list.ScrollToBottom()
183 return m.RestartPausedVisibleAnimations()
183 return m.RestartPausedVisibleAnimations()
184}
184}
185
185
186−// ScrollBy scrolls the chat view by the given number of line deltas and returns
186+// ScrollByAndAnimate scrolls the chat view by the given number of line deltas and returns
187// a command to restart any paused animations that are now visible.
187// a command to restart any paused animations that are now visible.
188−func (m *Chat) ScrollBy(lines int) tea.Cmd {
188+func (m *Chat) ScrollByAndAnimate(lines int) tea.Cmd {
189 m.list.ScrollBy(lines)
189 m.list.ScrollBy(lines)
190 return m.RestartPausedVisibleAnimations()
190 return m.RestartPausedVisibleAnimations()
191}
191}
192
192
193−// ScrollToSelected scrolls the chat view to the selected item and returns a
193+// ScrollToSelectedAndAnimate scrolls the chat view to the selected item and returns a
194// command to restart any paused animations that are now visible.
194// command to restart any paused animations that are now visible.
195−func (m *Chat) ScrollToSelected() tea.Cmd {
195+func (m *Chat) ScrollToSelectedAndAnimate() tea.Cmd {
196 m.list.ScrollToSelected()
196 m.list.ScrollToSelected()
197 return m.RestartPausedVisibleAnimations()
197 return m.RestartPausedVisibleAnimations()
198}
198}
internal/ui/model/ui.go+22−22
@@ -268,22 +268,22 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
268 switch m.state {
268 switch m.state {
269 case uiChat:
269 case uiChat:
270 if msg.Y <= 0 {
270 if msg.Y <= 0 {
271− if cmd := m.chat.ScrollBy(-1); cmd != nil {
271+ if cmd := m.chat.ScrollByAndAnimate(-1); cmd != nil {
272 cmds = append(cmds, cmd)
272 cmds = append(cmds, cmd)
273 }
273 }
274 if !m.chat.SelectedItemInView() {
274 if !m.chat.SelectedItemInView() {
275 m.chat.SelectPrev()
275 m.chat.SelectPrev()
276− if cmd := m.chat.ScrollToSelected(); cmd != nil {
276+ if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
277 cmds = append(cmds, cmd)
277 cmds = append(cmds, cmd)
278 }
278 }
279 }
279 }
280 } else if msg.Y >= m.chat.Height()-1 {
280 } else if msg.Y >= m.chat.Height()-1 {
281− if cmd := m.chat.ScrollBy(1); cmd != nil {
281+ if cmd := m.chat.ScrollByAndAnimate(1); cmd != nil {
282 cmds = append(cmds, cmd)
282 cmds = append(cmds, cmd)
283 }
283 }
284 if !m.chat.SelectedItemInView() {
284 if !m.chat.SelectedItemInView() {
285 m.chat.SelectNext()
285 m.chat.SelectNext()
286− if cmd := m.chat.ScrollToSelected(); cmd != nil {
286+ if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
287 cmds = append(cmds, cmd)
287 cmds = append(cmds, cmd)
288 }
288 }
289 }
289 }
@@ -310,22 +310,22 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
310 case uiChat:
310 case uiChat:
311 switch msg.Button {
311 switch msg.Button {
312 case tea.MouseWheelUp:
312 case tea.MouseWheelUp:
313− if cmd := m.chat.ScrollBy(-5); cmd != nil {
313+ if cmd := m.chat.ScrollByAndAnimate(-5); cmd != nil {
314 cmds = append(cmds, cmd)
314 cmds = append(cmds, cmd)
315 }
315 }
316 if !m.chat.SelectedItemInView() {
316 if !m.chat.SelectedItemInView() {
317 m.chat.SelectPrev()
317 m.chat.SelectPrev()
318− if cmd := m.chat.ScrollToSelected(); cmd != nil {
318+ if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
319 cmds = append(cmds, cmd)
319 cmds = append(cmds, cmd)
320 }
320 }
321 }
321 }
322 case tea.MouseWheelDown:
322 case tea.MouseWheelDown:
323− if cmd := m.chat.ScrollBy(5); cmd != nil {
323+ if cmd := m.chat.ScrollByAndAnimate(5); cmd != nil {
324 cmds = append(cmds, cmd)
324 cmds = append(cmds, cmd)
325 }
325 }
326 if !m.chat.SelectedItemInView() {
326 if !m.chat.SelectedItemInView() {
327 m.chat.SelectNext()
327 m.chat.SelectNext()
328− if cmd := m.chat.ScrollToSelected(); cmd != nil {
328+ if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
329 cmds = append(cmds, cmd)
329 cmds = append(cmds, cmd)
330 }
330 }
331 }
331 }
@@ -395,7 +395,7 @@ func (m *UI) setSessionMessages(msgs []message.Message) tea.Cmd {
395 }
395 }
396
396
397 m.chat.SetMessages(items...)
397 m.chat.SetMessages(items...)
398− if cmd := m.chat.ScrollToBottom(); cmd != nil {
398+ if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
399 cmds = append(cmds, cmd)
399 cmds = append(cmds, cmd)
400 }
400 }
401 m.chat.SelectLast()
401 m.chat.SelectLast()
@@ -414,7 +414,7 @@ func (m *UI) appendSessionMessage(msg message.Message) tea.Cmd {
414 }
414 }
415 }
415 }
416 m.chat.AppendMessages(items...)
416 m.chat.AppendMessages(items...)
417− if cmd := m.chat.ScrollToBottom(); cmd != nil {
417+ if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
418 cmds = append(cmds, cmd)
418 cmds = append(cmds, cmd)
419 }
419 }
420 return tea.Batch(cmds...)
420 return tea.Batch(cmds...)
@@ -580,62 +580,62 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
580 case key.Matches(msg, m.keyMap.Chat.Expand):
580 case key.Matches(msg, m.keyMap.Chat.Expand):
581 m.chat.ToggleExpandedSelectedItem()
581 m.chat.ToggleExpandedSelectedItem()
582 case key.Matches(msg, m.keyMap.Chat.Up):
582 case key.Matches(msg, m.keyMap.Chat.Up):
583− if cmd := m.chat.ScrollBy(-1); cmd != nil {
583+ if cmd := m.chat.ScrollByAndAnimate(-1); cmd != nil {
584 cmds = append(cmds, cmd)
584 cmds = append(cmds, cmd)
585 }
585 }
586 if !m.chat.SelectedItemInView() {
586 if !m.chat.SelectedItemInView() {
587 m.chat.SelectPrev()
587 m.chat.SelectPrev()
588− if cmd := m.chat.ScrollToSelected(); cmd != nil {
588+ if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
589 cmds = append(cmds, cmd)
589 cmds = append(cmds, cmd)
590 }
590 }
591 }
591 }
592 case key.Matches(msg, m.keyMap.Chat.Down):
592 case key.Matches(msg, m.keyMap.Chat.Down):
593− if cmd := m.chat.ScrollBy(1); cmd != nil {
593+ if cmd := m.chat.ScrollByAndAnimate(1); cmd != nil {
594 cmds = append(cmds, cmd)
594 cmds = append(cmds, cmd)
595 }
595 }
596 if !m.chat.SelectedItemInView() {
596 if !m.chat.SelectedItemInView() {
597 m.chat.SelectNext()
597 m.chat.SelectNext()
598− if cmd := m.chat.ScrollToSelected(); cmd != nil {
598+ if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
599 cmds = append(cmds, cmd)
599 cmds = append(cmds, cmd)
600 }
600 }
601 }
601 }
602 case key.Matches(msg, m.keyMap.Chat.UpOneItem):
602 case key.Matches(msg, m.keyMap.Chat.UpOneItem):
603 m.chat.SelectPrev()
603 m.chat.SelectPrev()
604− if cmd := m.chat.ScrollToSelected(); cmd != nil {
604+ if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
605 cmds = append(cmds, cmd)
605 cmds = append(cmds, cmd)
606 }
606 }
607 case key.Matches(msg, m.keyMap.Chat.DownOneItem):
607 case key.Matches(msg, m.keyMap.Chat.DownOneItem):
608 m.chat.SelectNext()
608 m.chat.SelectNext()
609− if cmd := m.chat.ScrollToSelected(); cmd != nil {
609+ if cmd := m.chat.ScrollToSelectedAndAnimate(); cmd != nil {
610 cmds = append(cmds, cmd)
610 cmds = append(cmds, cmd)
611 }
611 }
612 case key.Matches(msg, m.keyMap.Chat.HalfPageUp):
612 case key.Matches(msg, m.keyMap.Chat.HalfPageUp):
613− if cmd := m.chat.ScrollBy(-m.chat.Height() / 2); cmd != nil {
613+ if cmd := m.chat.ScrollByAndAnimate(-m.chat.Height() / 2); cmd != nil {
614 cmds = append(cmds, cmd)
614 cmds = append(cmds, cmd)
615 }
615 }
616 m.chat.SelectFirstInView()
616 m.chat.SelectFirstInView()
617 case key.Matches(msg, m.keyMap.Chat.HalfPageDown):
617 case key.Matches(msg, m.keyMap.Chat.HalfPageDown):
618− if cmd := m.chat.ScrollBy(m.chat.Height() / 2); cmd != nil {
618+ if cmd := m.chat.ScrollByAndAnimate(m.chat.Height() / 2); cmd != nil {
619 cmds = append(cmds, cmd)
619 cmds = append(cmds, cmd)
620 }
620 }
621 m.chat.SelectLastInView()
621 m.chat.SelectLastInView()
622 case key.Matches(msg, m.keyMap.Chat.PageUp):
622 case key.Matches(msg, m.keyMap.Chat.PageUp):
623− if cmd := m.chat.ScrollBy(-m.chat.Height()); cmd != nil {
623+ if cmd := m.chat.ScrollByAndAnimate(-m.chat.Height()); cmd != nil {
624 cmds = append(cmds, cmd)
624 cmds = append(cmds, cmd)
625 }
625 }
626 m.chat.SelectFirstInView()
626 m.chat.SelectFirstInView()
627 case key.Matches(msg, m.keyMap.Chat.PageDown):
627 case key.Matches(msg, m.keyMap.Chat.PageDown):
628− if cmd := m.chat.ScrollBy(m.chat.Height()); cmd != nil {
628+ if cmd := m.chat.ScrollByAndAnimate(m.chat.Height()); cmd != nil {
629 cmds = append(cmds, cmd)
629 cmds = append(cmds, cmd)
630 }
630 }
631 m.chat.SelectLastInView()
631 m.chat.SelectLastInView()
632 case key.Matches(msg, m.keyMap.Chat.Home):
632 case key.Matches(msg, m.keyMap.Chat.Home):
633− if cmd := m.chat.ScrollToTop(); cmd != nil {
633+ if cmd := m.chat.ScrollToTopAndAnimate(); cmd != nil {
634 cmds = append(cmds, cmd)
634 cmds = append(cmds, cmd)
635 }
635 }
636 m.chat.SelectFirst()
636 m.chat.SelectFirst()
637 case key.Matches(msg, m.keyMap.Chat.End):
637 case key.Matches(msg, m.keyMap.Chat.End):
638− if cmd := m.chat.ScrollToBottom(); cmd != nil {
638+ if cmd := m.chat.ScrollToBottomAndAnimate(); cmd != nil {
639 cmds = append(cmds, cmd)
639 cmds = append(cmds, cmd)
640 }
640 }
641 m.chat.SelectLast()
641 m.chat.SelectLast()