Simplify ConversationListBox ctor args substantially
Remove all redundant args that could be obtained from the conversation itself.
This commit is contained in:
parent
2a997ef33e
commit
816743caa3
3 changed files with 54 additions and 54 deletions
|
|
@ -1251,22 +1251,32 @@ public class GearyController : Geary.BaseObject {
|
|||
case 1:
|
||||
// Cancel existing avatar loads before loading new
|
||||
// convo since that will start loading more avatars
|
||||
viewer.load_conversation.begin(
|
||||
Geary.Collection.get_first(selected),
|
||||
this.current_folder,
|
||||
this.application.config,
|
||||
this.avatar_store,
|
||||
(obj, ret) => {
|
||||
try {
|
||||
viewer.load_conversation.end(ret);
|
||||
enable_message_buttons(true);
|
||||
get_window_action(ACTION_FIND_IN_CONVERSATION).set_enabled(true);
|
||||
} catch (Error err) {
|
||||
debug("Unable to load conversation: %s",
|
||||
err.message);
|
||||
}
|
||||
}
|
||||
Geary.App.Conversation convo = Geary.Collection.get_first(
|
||||
selected
|
||||
);
|
||||
Geary.App.EmailStore? store = get_store_for_folder(
|
||||
convo.base_folder
|
||||
);
|
||||
if (store != null) {
|
||||
viewer.load_conversation.begin(
|
||||
convo,
|
||||
store,
|
||||
this.avatar_store,
|
||||
this.application.config,
|
||||
(obj, ret) => {
|
||||
try {
|
||||
viewer.load_conversation.end(ret);
|
||||
enable_message_buttons(true);
|
||||
get_window_action(
|
||||
ACTION_FIND_IN_CONVERSATION
|
||||
).set_enabled(true);
|
||||
} catch (Error err) {
|
||||
debug("Unable to load conversation: %s",
|
||||
err.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -287,20 +287,14 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
|
|||
/** Conversation being displayed. */
|
||||
public Geary.App.Conversation conversation { get; private set; }
|
||||
|
||||
// Folder from which the conversation was loaded
|
||||
internal Geary.Folder location { get; private set; }
|
||||
|
||||
// Used to load messages in conversation.
|
||||
private Geary.App.EmailStore email_store;
|
||||
|
||||
// Contacts for the account this conversation exists in
|
||||
private Geary.ContactStore contact_store;
|
||||
|
||||
// Avatars for this conversation
|
||||
private Application.AvatarStore avatar_store;
|
||||
|
||||
// Account this conversation belongs to
|
||||
private Geary.AccountInformation account_info;
|
||||
// App config
|
||||
private Configuration config;
|
||||
|
||||
// Was this conversation loaded from the drafts folder?
|
||||
private bool is_draft_folder;
|
||||
|
|
@ -308,9 +302,6 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
|
|||
// Cancellable for this conversation's data loading.
|
||||
private Cancellable cancellable = new Cancellable();
|
||||
|
||||
// App config
|
||||
private Configuration config;
|
||||
|
||||
// Email view with selected text, if any
|
||||
private ConversationEmail? body_selected_view = null;
|
||||
|
||||
|
|
@ -392,24 +383,21 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
|
|||
* Constructs a new conversation list box instance.
|
||||
*/
|
||||
public ConversationListBox(Geary.App.Conversation conversation,
|
||||
Geary.Folder location,
|
||||
Geary.App.EmailStore? email_store,
|
||||
Geary.ContactStore contact_store,
|
||||
Geary.AccountInformation account_info,
|
||||
bool is_draft_folder,
|
||||
Configuration config,
|
||||
Geary.App.EmailStore email_store,
|
||||
Application.AvatarStore avatar_store,
|
||||
Configuration config,
|
||||
Gtk.Adjustment adjustment) {
|
||||
base_ref();
|
||||
this.conversation = conversation;
|
||||
this.location = location;
|
||||
this.email_store = email_store;
|
||||
this.contact_store = contact_store;
|
||||
this.avatar_store = avatar_store;
|
||||
this.account_info = account_info;
|
||||
this.is_draft_folder = is_draft_folder;
|
||||
this.config = config;
|
||||
|
||||
this.is_draft_folder = (
|
||||
conversation.base_folder.special_folder_type ==
|
||||
Geary.SpecialFolderType.DRAFTS
|
||||
);
|
||||
|
||||
get_style_context().add_class("background");
|
||||
get_style_context().add_class("conversation-listbox");
|
||||
|
||||
|
|
@ -603,8 +591,12 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
|
|||
* Loads search term matches for this list's emails.
|
||||
*/
|
||||
public async void load_search_terms() {
|
||||
Geary.SearchFolder search = (Geary.SearchFolder) this.location;
|
||||
Geary.SearchQuery? query = search.search_query;
|
||||
Geary.SearchFolder? search_folder =
|
||||
this.conversation.base_folder as Geary.SearchFolder;
|
||||
Geary.SearchQuery? query = null;
|
||||
if (search_folder != null) {
|
||||
query = search_folder.search_query;
|
||||
}
|
||||
if (query != null) {
|
||||
|
||||
// List all IDs of emails we're viewing.
|
||||
|
|
@ -619,7 +611,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
|
|||
|
||||
Gee.Set<string>? search_matches = null;
|
||||
try {
|
||||
search_matches = yield search.get_search_matches_async(
|
||||
search_matches = yield search_folder.get_search_matches_async(
|
||||
ids, cancellable
|
||||
);
|
||||
} catch (Error e) {
|
||||
|
|
@ -764,9 +756,10 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
|
|||
bool is_draft = (this.is_draft_folder && is_in_folder);
|
||||
|
||||
bool is_sent = false;
|
||||
Geary.Account account = this.conversation.base_folder.account;
|
||||
if (email.from != null) {
|
||||
foreach (Geary.RFC822.MailboxAddress from in email.from) {
|
||||
if (this.account_info.has_sender_mailbox(from)) {
|
||||
if (account.information.has_sender_mailbox(from)) {
|
||||
is_sent = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -775,7 +768,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
|
|||
|
||||
ConversationEmail view = new ConversationEmail(
|
||||
email,
|
||||
this.contact_store,
|
||||
account.get_contact_store(),
|
||||
this.config,
|
||||
is_sent,
|
||||
is_draft,
|
||||
|
|
|
|||
|
|
@ -197,22 +197,17 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
|
|||
* Shows a conversation in the viewer.
|
||||
*/
|
||||
public async void load_conversation(Geary.App.Conversation conversation,
|
||||
Geary.Folder location,
|
||||
Configuration config,
|
||||
Application.AvatarStore avatars)
|
||||
throws Error {
|
||||
Geary.App.EmailStore email_store,
|
||||
Application.AvatarStore avatar_store,
|
||||
Configuration config)
|
||||
throws GLib.Error {
|
||||
remove_current_list();
|
||||
|
||||
Geary.Account account = location.account;
|
||||
ConversationListBox new_list = new ConversationListBox(
|
||||
conversation,
|
||||
location,
|
||||
new Geary.App.EmailStore(account),
|
||||
account.get_contact_store(),
|
||||
account.information,
|
||||
location.special_folder_type == Geary.SpecialFolderType.DRAFTS,
|
||||
email_store,
|
||||
avatar_store,
|
||||
config,
|
||||
avatars,
|
||||
this.conversation_scroller.get_vadjustment()
|
||||
);
|
||||
|
||||
|
|
@ -247,7 +242,8 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
|
|||
|
||||
// Highlight matching terms from the search if it exists, but
|
||||
// don't clobber any find terms.
|
||||
if (find_terms == null && location is Geary.SearchFolder) {
|
||||
if (find_terms == null &&
|
||||
conversation.base_folder is Geary.SearchFolder) {
|
||||
yield new_list.load_search_terms();
|
||||
}
|
||||
}
|
||||
|
|
@ -348,7 +344,8 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
|
|||
} else {
|
||||
// Find was disabled
|
||||
this.current_list.unmark_search_terms();
|
||||
if (!(this.current_list.location is Geary.SearchFolder)) {
|
||||
if (!(this.current_list.conversation.base_folder
|
||||
is Geary.SearchFolder)) {
|
||||
//this.current_list.update_collapsed_state();
|
||||
} else {
|
||||
this.current_list.load_search_terms.begin();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue