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}
113
114type AttachmentDownloadedMsg struct {
115	Path string
116	Err  error
117}
118
119type RestoreViewMsg struct{}
120
121type BackToInboxMsg struct{}
122
123// --- Draft Messages ---
124
125// DiscardDraftMsg signals that a draft should be cached.
126type DiscardDraftMsg struct {
127	ComposerState *Composer
128}
129
130// RestoreDraftMsg signals that the cached draft should be restored.
131type RestoreDraftMsg struct{}
132
133type EmailBodyFetchedMsg struct {
134	UID         uint32
135	Body        string
136	Attachments []fetcher.Attachment
137	Err         error
138	AccountID   string
139}
140
141// --- Multi-Account Messages ---
142
143// GoToAddAccountMsg signals navigation to the add account screen.
144type GoToAddAccountMsg struct{}
145
146// AddAccountMsg signals that a new account should be added.
147type AddAccountMsg struct {
148	Credentials Credentials
149}
150
151// AccountAddedMsg signals that an account was successfully added.
152type AccountAddedMsg struct {
153	AccountID string
154	Err       error
155}
156
157// DeleteAccountMsg signals that an account should be deleted.
158type DeleteAccountMsg struct {
159	AccountID string
160}
161
162// AccountDeletedMsg signals that an account was successfully deleted.
163type AccountDeletedMsg struct {
164	AccountID string
165	Err       error
166}
167
168// SwitchAccountMsg signals switching to view a specific account's inbox.
169type SwitchAccountMsg struct {
170	AccountID string // Empty string means "ALL" accounts
171}
172
173// AllEmailsFetchedMsg signals that emails from all accounts have been fetched.
174type AllEmailsFetchedMsg struct {
175	EmailsByAccount map[string][]fetcher.Email
176}
177
178// SwitchFromAccountMsg signals changing the "From" account in composer.
179type SwitchFromAccountMsg struct {
180	AccountID string
181}
182
183// GoToAccountListMsg signals navigation to the account list in settings.
184type GoToAccountListMsg struct{}
185
186// --- Draft Messages (persisted) ---
187
188// SaveDraftMsg signals that the current draft should be saved to disk.
189type SaveDraftMsg struct {
190	Draft config.Draft
191}
192
193// DraftSavedMsg signals that a draft was saved successfully.
194type DraftSavedMsg struct {
195	DraftID string
196	Err     error
197}
198
199// LoadDraftsMsg signals a request to load all saved drafts.
200type LoadDraftsMsg struct{}
201
202// DraftsLoadedMsg signals that drafts were loaded from disk.
203type DraftsLoadedMsg struct {
204	Drafts []config.Draft
205}
206
207// OpenDraftMsg signals that a specific draft should be opened in the composer.
208type OpenDraftMsg struct {
209	Draft config.Draft
210}
211
212// DeleteDraftMsg signals that a draft should be deleted.
213type DeleteSavedDraftMsg struct {
214	DraftID string
215}
216
217// DraftDeletedMsg signals that a draft was deleted.
218type DraftDeletedMsg struct {
219	DraftID string
220	Err     error
221}
222
223// GoToDraftsMsg signals navigation to the drafts list.
224type GoToDraftsMsg struct{}
225
226// --- Cache Messages ---
227
228// CachedEmailsLoadedMsg signals that cached emails were loaded from disk.
229type CachedEmailsLoadedMsg struct {
230	Cache *config.EmailCache
231}
232
233// RefreshingEmailsMsg signals that a background refresh is in progress.
234type RefreshingEmailsMsg struct{}
235
236// EmailsRefreshedMsg signals that fresh emails have been fetched in the background.
237type EmailsRefreshedMsg struct {
238	EmailsByAccount map[string][]fetcher.Email
239}