mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
Mail: Mark mail as seen after open
This commit is contained in:
parent
619b53eaca
commit
f9a006d092
4 changed files with 19 additions and 2 deletions
|
@ -13,6 +13,12 @@ InboxModel::InboxModel(Vector<InboxEntry> entries)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InboxModel::set_seen(int row, bool seen)
|
||||||
|
{
|
||||||
|
m_entries[row].seen = seen;
|
||||||
|
did_update(DontInvalidateIndices);
|
||||||
|
}
|
||||||
|
|
||||||
int InboxModel::row_count(GUI::ModelIndex const&) const
|
int InboxModel::row_count(GUI::ModelIndex const&) const
|
||||||
{
|
{
|
||||||
return m_entries.size();
|
return m_entries.size();
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
|
|
||||||
virtual ~InboxModel() override = default;
|
virtual ~InboxModel() override = default;
|
||||||
|
|
||||||
|
void set_seen(int row, bool);
|
||||||
|
|
||||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
|
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
|
||||||
virtual ErrorOr<String> column_name(int) const override;
|
virtual ErrorOr<String> column_name(int) const override;
|
||||||
|
|
|
@ -243,7 +243,8 @@ bool MailWidget::is_supported_alternative(Alternative const& alternative) const
|
||||||
|
|
||||||
void MailWidget::selected_mailbox()
|
void MailWidget::selected_mailbox()
|
||||||
{
|
{
|
||||||
m_individual_mailbox_view->set_model(InboxModel::create({}));
|
m_individual_mailbox_model = InboxModel::create({});
|
||||||
|
m_individual_mailbox_view->set_model(m_individual_mailbox_model);
|
||||||
|
|
||||||
auto const& index = m_mailbox_list->selection().first();
|
auto const& index = m_mailbox_list->selection().first();
|
||||||
|
|
||||||
|
@ -427,7 +428,8 @@ void MailWidget::selected_mailbox()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_statusbar->set_text(String::formatted("[{}]: Loaded {} entries", mailbox.name, i).release_value_but_fixme_should_propagate_errors());
|
m_statusbar->set_text(String::formatted("[{}]: Loaded {} entries", mailbox.name, i).release_value_but_fixme_should_propagate_errors());
|
||||||
m_individual_mailbox_view->set_model(InboxModel::create(move(active_inbox_entries)));
|
m_individual_mailbox_model = InboxModel::create(move(active_inbox_entries));
|
||||||
|
m_individual_mailbox_view->set_model(m_individual_mailbox_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MailWidget::selected_email_to_load()
|
void MailWidget::selected_email_to_load()
|
||||||
|
@ -509,6 +511,9 @@ void MailWidget::selected_email_to_load()
|
||||||
},
|
},
|
||||||
.partial_fetch = false,
|
.partial_fetch = false,
|
||||||
},
|
},
|
||||||
|
IMAP::FetchCommand::DataItem {
|
||||||
|
.type = IMAP::FetchCommand::DataItemType::Flags,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -532,6 +537,9 @@ void MailWidget::selected_email_to_load()
|
||||||
|
|
||||||
auto& fetch_response_data = fetch_data.last().get<IMAP::FetchResponseData>();
|
auto& fetch_response_data = fetch_data.last().get<IMAP::FetchResponseData>();
|
||||||
|
|
||||||
|
auto seen = !fetch_response_data.flags().find_if([](StringView value) { return value.equals_ignoring_ascii_case("\\Seen"sv); }).is_end();
|
||||||
|
m_individual_mailbox_model->set_seen(index.row(), seen);
|
||||||
|
|
||||||
if (!fetch_response_data.contains_response_type(IMAP::FetchResponseType::Body)) {
|
if (!fetch_response_data.contains_response_type(IMAP::FetchResponseType::Body)) {
|
||||||
GUI::MessageBox::show_error(window(), "The server sent no body."sv);
|
GUI::MessageBox::show_error(window(), "The server sent no body."sv);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -41,6 +41,7 @@ private:
|
||||||
OwnPtr<IMAP::Client> m_imap_client;
|
OwnPtr<IMAP::Client> m_imap_client;
|
||||||
|
|
||||||
RefPtr<GUI::TreeView> m_mailbox_list;
|
RefPtr<GUI::TreeView> m_mailbox_list;
|
||||||
|
RefPtr<InboxModel> m_individual_mailbox_model;
|
||||||
RefPtr<GUI::TableView> m_individual_mailbox_view;
|
RefPtr<GUI::TableView> m_individual_mailbox_view;
|
||||||
RefPtr<WebView::OutOfProcessWebView> m_web_view;
|
RefPtr<WebView::OutOfProcessWebView> m_web_view;
|
||||||
RefPtr<GUI::Statusbar> m_statusbar;
|
RefPtr<GUI::Statusbar> m_statusbar;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue