messages.go

  1package tui
  2
  3import (
  4	"github.com/floatpane/matcha/config"
  5	"github.com/floatpane/matcha/fetcher"
  6)
  7
  8type ViewEmailMsg struct {
  9	Index     int
 10	UID       uint32
 11	AccountID string
 12}
 13
 14type SendEmailMsg struct {
 15	To             string
 16	Subject        string
 17	Body           string
 18	AttachmentPath string
 19	InReplyTo      string
 20	References     []string
 21	AccountID      string // ID of the account to send from
 22}
 23
 24type Credentials struct {
 25	Provider   string
 26	Name       string
 27	Email      string
 28	Password   string
 29	IMAPServer string
 30	IMAPPort   int
 31	SMTPServer string
 32	SMTPPort   int
 33}
 34
 35type ChooseServiceMsg struct {
 36	Service string
 37}
 38
 39type EmailResultMsg struct {
 40	Err error
 41}
 42
 43type ClearStatusMsg struct{}
 44
 45type EmailsFetchedMsg struct {
 46	Emails    []fetcher.Email
 47	AccountID string
 48}
 49
 50type FetchErr error
 51
 52type GoToInboxMsg struct{}
 53
 54type GoToSendMsg struct {
 55	To      string
 56	Subject string
 57	Body    string
 58}
 59
 60type GoToSettingsMsg struct{}
 61
 62type FetchMoreEmailsMsg struct {
 63	Offset    uint32
 64	AccountID string
 65}
 66
 67type FetchingMoreEmailsMsg struct{}
 68
 69type EmailsAppendedMsg struct {
 70	Emails    []fetcher.Email
 71	AccountID string
 72}
 73
 74type ReplyToEmailMsg struct {
 75	Email fetcher.Email
 76}
 77
 78type SetComposerCursorToStartMsg struct{}
 79
 80type GoToFilePickerMsg struct{}
 81
 82type FileSelectedMsg struct {
 83	Path string
 84}
 85
 86type CancelFilePickerMsg struct{}
 87
 88type DeleteEmailMsg struct {
 89	UID       uint32
 90	AccountID string
 91}
 92
 93type ArchiveEmailMsg struct {
 94	UID       uint32
 95	AccountID string
 96}
 97
 98type EmailActionDoneMsg struct {
 99	UID       uint32
100	AccountID string
101	Err       error
102}
103
104type GoToChoiceMenuMsg struct{}
105
106type DownloadAttachmentMsg struct {
107	Index     int
108	Filename  string
109	PartID    string
110	Data      []byte
111	AccountID string
112	Encoding  string
113}
114
115type AttachmentDownloadedMsg struct {
116	Path string
117	Err  error
118}
119
120type RestoreViewMsg struct{}
121
122type BackToInboxMsg struct{}
123
124// --- Draft Messages ---
125
126// DiscardDraftMsg signals that a draft should be cached.
127type DiscardDraftMsg struct {
128	ComposerState *Composer
129}
130
131type EmailBodyFetchedMsg struct {
132	UID         uint32
133	Body        string
134	Attachments []fetcher.Attachment
135	Err         error
136	AccountID   string
137}
138
139// --- Multi-Account Messages ---
140
141// GoToAddAccountMsg signals navigation to the add account screen.
142type GoToAddAccountMsg struct{}
143
144// AddAccountMsg signals that a new account should be added.
145type AddAccountMsg struct {
146	Credentials Credentials
147}
148
149// AccountAddedMsg signals that an account was successfully added.
150type AccountAddedMsg struct {
151	AccountID string
152	Err       error
153}
154
155// DeleteAccountMsg signals that an account should be deleted.
156type DeleteAccountMsg struct {
157	AccountID string
158}
159
160// AccountDeletedMsg signals that an account was successfully deleted.
161type AccountDeletedMsg struct {
162	AccountID string
163	Err       error
164}
165
166// SwitchAccountMsg signals switching to view a specific account's inbox.
167type SwitchAccountMsg struct {
168	AccountID string // Empty string means "ALL" accounts
169}
170
171// AllEmailsFetchedMsg signals that emails from all accounts have been fetched.
172type AllEmailsFetchedMsg struct {
173	EmailsByAccount map[string][]fetcher.Email
174}
175
176// SwitchFromAccountMsg signals changing the "From" account in composer.
177type SwitchFromAccountMsg struct {
178	AccountID string
179}
180
181// GoToAccountListMsg signals navigation to the account list in settings.
182type GoToAccountListMsg struct{}
183
184// --- Draft Messages (persisted) ---
185
186// SaveDraftMsg signals that the current draft should be saved to disk.
187type SaveDraftMsg struct {
188	Draft config.Draft
189}
190
191// DraftSavedMsg signals that a draft was saved successfully.
192type DraftSavedMsg struct {
193	DraftID string
194	Err     error
195}
196
197// LoadDraftsMsg signals a request to load all saved drafts.
198type LoadDraftsMsg struct{}
199
200// DraftsLoadedMsg signals that drafts were loaded from disk.
201type DraftsLoadedMsg struct {
202	Drafts []config.Draft
203}
204
205// OpenDraftMsg signals that a specific draft should be opened in the composer.
206type OpenDraftMsg struct {
207	Draft config.Draft
208}
209
210// DeleteDraftMsg signals that a draft should be deleted.
211type DeleteSavedDraftMsg struct {
212	DraftID string
213}
214
215// DraftDeletedMsg signals that a draft was deleted.
216type DraftDeletedMsg struct {
217	DraftID string
218	Err     error
219}
220
221// GoToDraftsMsg signals navigation to the drafts list.
222type GoToDraftsMsg struct{}
223
224// --- Cache Messages ---
225
226// CachedEmailsLoadedMsg signals that cached emails were loaded from disk.
227type CachedEmailsLoadedMsg struct {
228	Cache *config.EmailCache
229}
230
231// RefreshingEmailsMsg signals that a background refresh is in progress.
232type RefreshingEmailsMsg struct{}
233
234// EmailsRefreshedMsg signals that fresh emails have been fetched in the background.
235type EmailsRefreshedMsg struct {
236	EmailsByAccount map[string][]fetcher.Email
237}