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