messages.go

  1package tui
  2
  3import "github.com/floatpane/matcha/fetcher"
  4
  5type ViewEmailMsg struct {
  6	Index     int
  7	UID       uint32
  8	AccountID string
  9}
 10
 11type SendEmailMsg struct {
 12	To             string
 13	Subject        string
 14	Body           string
 15	AttachmentPath string
 16	InReplyTo      string
 17	References     []string
 18	AccountID      string // ID of the account to send from
 19}
 20
 21type Credentials struct {
 22	Provider   string
 23	Name       string
 24	Email      string
 25	Password   string
 26	IMAPServer string
 27	IMAPPort   int
 28	SMTPServer string
 29	SMTPPort   int
 30}
 31
 32type ChooseServiceMsg struct {
 33	Service string
 34}
 35
 36type EmailResultMsg struct {
 37	Err error
 38}
 39
 40type ClearStatusMsg struct{}
 41
 42type EmailsFetchedMsg struct {
 43	Emails    []fetcher.Email
 44	AccountID string
 45}
 46
 47type FetchErr error
 48
 49type GoToInboxMsg struct{}
 50
 51type GoToSendMsg struct {
 52	To      string
 53	Subject string
 54	Body    string
 55}
 56
 57type GoToSettingsMsg struct{}
 58
 59type FetchMoreEmailsMsg struct {
 60	Offset    uint32
 61	AccountID string
 62}
 63
 64type FetchingMoreEmailsMsg struct{}
 65
 66type EmailsAppendedMsg struct {
 67	Emails    []fetcher.Email
 68	AccountID string
 69}
 70
 71type ReplyToEmailMsg struct {
 72	Email fetcher.Email
 73}
 74
 75type SetComposerCursorToStartMsg struct{}
 76
 77type GoToFilePickerMsg struct{}
 78
 79type FileSelectedMsg struct {
 80	Path string
 81}
 82
 83type CancelFilePickerMsg struct{}
 84
 85type DeleteEmailMsg struct {
 86	UID       uint32
 87	AccountID string
 88}
 89
 90type ArchiveEmailMsg struct {
 91	UID       uint32
 92	AccountID string
 93}
 94
 95type EmailActionDoneMsg struct {
 96	UID       uint32
 97	AccountID string
 98	Err       error
 99}
100
101type GoToChoiceMenuMsg struct{}
102
103type DownloadAttachmentMsg struct {
104	Index     int
105	Filename  string
106	PartID    string
107	Data      []byte
108	AccountID string
109}
110
111type AttachmentDownloadedMsg struct {
112	Path string
113	Err  error
114}
115
116type RestoreViewMsg struct{}
117
118type BackToInboxMsg struct{}
119
120// --- Draft Messages ---
121
122// DiscardDraftMsg signals that a draft should be cached.
123type DiscardDraftMsg struct {
124	ComposerState *Composer
125}
126
127// RestoreDraftMsg signals that the cached draft should be restored.
128type RestoreDraftMsg struct{}
129
130type EmailBodyFetchedMsg struct {
131	UID         uint32
132	Body        string
133	Attachments []fetcher.Attachment
134	Err         error
135	AccountID   string
136}
137
138// --- Multi-Account Messages ---
139
140// GoToAddAccountMsg signals navigation to the add account screen.
141type GoToAddAccountMsg struct{}
142
143// AddAccountMsg signals that a new account should be added.
144type AddAccountMsg struct {
145	Credentials Credentials
146}
147
148// AccountAddedMsg signals that an account was successfully added.
149type AccountAddedMsg struct {
150	AccountID string
151	Err       error
152}
153
154// DeleteAccountMsg signals that an account should be deleted.
155type DeleteAccountMsg struct {
156	AccountID string
157}
158
159// AccountDeletedMsg signals that an account was successfully deleted.
160type AccountDeletedMsg struct {
161	AccountID string
162	Err       error
163}
164
165// SwitchAccountMsg signals switching to view a specific account's inbox.
166type SwitchAccountMsg struct {
167	AccountID string // Empty string means "ALL" accounts
168}
169
170// AllEmailsFetchedMsg signals that emails from all accounts have been fetched.
171type AllEmailsFetchedMsg struct {
172	EmailsByAccount map[string][]fetcher.Email
173}
174
175// SwitchFromAccountMsg signals changing the "From" account in composer.
176type SwitchFromAccountMsg struct {
177	AccountID string
178}
179
180// GoToAccountListMsg signals navigation to the account list in settings.
181type GoToAccountListMsg struct{}