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