contacts

package
v0.0.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContactSelectedMsg

type ContactSelectedMsg struct {
	UserId int64
}

ContactSelectedMsg is emitted when a contact is selected.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the contact list component.

func New

func New(s *store.Store, tg *telegram.Client, r theme.Roles) Model

New creates a new contacts model.

func (*Model) ClearFilter added in v0.0.17

func (m *Model) ClearFilter()

ClearFilter drops the filter and closes the input, restoring the whole contact list. This is what `esc` does inside the input.

func (*Model) ClickAt

func (m *Model) ClickAt(localY int) (userID int64, ok bool)

ClickAt selects the contact shown at the given local row and returns its user ID. ok is false when the row has no contact — including row 0, which is the filter header rather than a contact.

func (Model) FilterActive added in v0.0.17

func (m Model) FilterActive() bool

FilterActive reports whether the filter input is open and consuming keys. False once it closes, INCLUDING while a filter is still applied (`enter`) — that is a normal browsing state in which j/k and enter work as usual.

func (Model) FilterQuery added in v0.0.17

func (m Model) FilterQuery() string

FilterQuery is the applied filter, "" when none.

func (Model) IsVisible

func (m Model) IsVisible() bool

IsVisible returns whether the contacts panel is visible.

func (*Model) LoadContacts

func (m *Model) LoadContacts() tea.Cmd

LoadContacts fetches the contact list.

func (*Model) OpenFilter added in v0.0.17

func (m *Model) OpenFilter()

OpenFilter opens the filter input over the contact list.

The caller has consumed the key that asked for it: internal/app matches keys.search and returns, so this component never sees that press. The next key it does see is the first character of the query, and a "/" among them is a literal — a swallow here would make a query starting with one impossible to type.

func (*Model) ScrollBy

func (m *Model) ScrollBy(n int)

ScrollBy moves the selection by n items (negative scrolls up).

func (*Model) SetContactsForTest added in v0.0.17

func (m *Model) SetContactsForTest(users []*telegram.User)

SetContactsForTest seeds the list without a Telegram client, so a caller in another package can render the column. The load path is otherwise the only way in, and it needs a live connection.

func (*Model) SetFocused

func (m *Model) SetFocused(focused bool)

SetFocused sets focus state.

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize sets the component dimensions.

func (*Model) SetVisible

func (m *Model) SetVisible(visible bool)

SetVisible shows or hides the contacts panel.

Closing it drops any filter. The panel is opened to look somebody up, and a reader who narrowed it to one name, closed it, and came back to a list of one would be reading a state they had forgotten setting — the header says why, but "why is this list short" is a question the panel should not be asking on the way in.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update handles messages.

func (Model) View

func (m Model) View() string

View renders the contact list into the column the chat list otherwise occupies: a filter header and then the rows, on the same grid, with no frame of its own.

It used to render a bold "Contacts" heading over a box it sized itself, which is the pre-2.0 overlay idiom — a different palette and a different geometry from the column it was drawn into. The frame owns the surface; this returns lines and lets it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL