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
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{}
182
183// --- Draft Messages (persisted) ---
184
185// SaveDraftMsg signals that the current draft should be saved to disk.
186type SaveDraftMsg struct {
187 Draft config.Draft
188}
189
190// DraftSavedMsg signals that a draft was saved successfully.
191type DraftSavedMsg struct {
192 DraftID string
193 Err error
194}
195
196// LoadDraftsMsg signals a request to load all saved drafts.
197type LoadDraftsMsg struct{}
198
199// DraftsLoadedMsg signals that drafts were loaded from disk.
200type DraftsLoadedMsg struct {
201 Drafts []config.Draft
202}
203
204// OpenDraftMsg signals that a specific draft should be opened in the composer.
205type OpenDraftMsg struct {
206 Draft config.Draft
207}
208
209// DeleteDraftMsg signals that a draft should be deleted.
210type DeleteSavedDraftMsg struct {
211 DraftID string
212}
213
214// DraftDeletedMsg signals that a draft was deleted.
215type DraftDeletedMsg struct {
216 DraftID string
217 Err error
218}
219
220// GoToDraftsMsg signals navigation to the drafts list.
221type GoToDraftsMsg struct{}
222
223// --- Cache Messages ---
224
225// CachedEmailsLoadedMsg signals that cached emails were loaded from disk.
226type CachedEmailsLoadedMsg struct {
227 Cache *config.EmailCache
228}
229
230// RefreshingEmailsMsg signals that a background refresh is in progress.
231type RefreshingEmailsMsg struct{}
232
233// EmailsRefreshedMsg signals that fresh emails have been fetched in the background.
234type EmailsRefreshedMsg struct {
235 EmailsByAccount map[string][]fetcher.Email
236}