1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:27:46 +00:00

Mail: Fetch mails with their sequence number

The FETCH response doesn't have return the sequence in order, or at very
least one of my mail providers doesn't do it.
This commit is contained in:
Karol Kosek 2023-08-29 15:44:13 +02:00 committed by Andrew Kaster
parent 720c27efbd
commit 0132c30eda
3 changed files with 11 additions and 3 deletions

View file

@ -57,5 +57,7 @@ GUI::Variant InboxModel::data(GUI::ModelIndex const& index, GUI::ModelRole role)
if (!value.seen)
return Gfx::FontDatabase::default_font().bold_variant();
}
if (role == static_cast<GUI::ModelRole>(InboxModelCustomRole::Sequence))
return value.sequence_number;
return {};
}

View file

@ -11,12 +11,18 @@
#include <LibIMAP/Objects.h>
struct InboxEntry {
u32 sequence_number;
DeprecatedString from;
DeprecatedString subject;
DeprecatedString date;
bool seen;
};
enum class InboxModelCustomRole {
__DONOTUSE = (int)GUI::ModelRole::Custom,
Sequence,
};
class InboxModel final : public GUI::Model {
public:
enum Column {

View file

@ -309,6 +309,7 @@ void MailWidget::selected_mailbox()
int i = 0;
for (auto& fetch_data : fetch_response.data().fetch_data()) {
auto sequence_number = fetch_data.get<unsigned>();
auto& response_data = fetch_data.get<IMAP::FetchResponseData>();
auto& body_data = response_data.body_data();
@ -420,7 +421,7 @@ void MailWidget::selected_mailbox()
if (from.is_empty())
from = "(Unknown sender)";
InboxEntry inbox_entry { from, subject, date, seen };
InboxEntry inbox_entry { sequence_number, from, subject, date, seen };
m_statusbar->set_text(String::formatted("[{}]: Loading entry {}", mailbox.name, ++i).release_value_but_fixme_should_propagate_errors());
active_inbox_entries.append(inbox_entry);
@ -438,8 +439,7 @@ void MailWidget::selected_email_to_load()
if (!index.is_valid())
return;
// IMAP is 1-based.
int id_of_email_to_load = index.row() + 1;
int id_of_email_to_load = index.data(static_cast<GUI::ModelRole>(InboxModelCustomRole::Sequence)).as_u32();
m_statusbar->set_text("Fetching message..."_string);