Jump to furst unread message when selecting a conversation: Closes #6243
Although a duplicate of #4639, where we decided not to implement this feature in lieu of implementing #5137 (compress collapsed read messages), since we don't know when that will be ready, this is a good stop-gap, as current behavior is annoying with long conversations. Andrea's code is cleanly delineated from the other code, and should be easily removed if/when the time comes.
This commit is contained in:
parent
e51f678763
commit
593abc80af
3 changed files with 24 additions and 0 deletions
|
|
@ -549,6 +549,7 @@ public class GearyController {
|
|||
main_window.conversation_viewer.add_message(email);
|
||||
|
||||
main_window.conversation_viewer.unhide_last_email();
|
||||
main_window.conversation_viewer.show_first_visible_email();
|
||||
}
|
||||
|
||||
private void on_show_message_completed(Object? source, AsyncResult result) {
|
||||
|
|
|
|||
|
|
@ -339,6 +339,25 @@ public class ConversationViewer : Gtk.Box {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void show_first_visible_email() {
|
||||
// Select the first email element that does not have "hide" in its
|
||||
// class list. The constraint on the id is required because there
|
||||
// are some elements (like #selection_counter) that have the "email"
|
||||
// class, but that are not messages.
|
||||
WebKit.DOM.HTMLElement first_visible_email =
|
||||
Util.DOM.select(web_view.get_dom_document(), ".email[id^=message_]:not(.hide)");
|
||||
if (first_visible_email != null) {
|
||||
// Select the sibling which, if it exists, is the previous hidden
|
||||
// message. This is a way Geary has to say "hey, this conversation
|
||||
// is not new: there are some messages above".
|
||||
WebKit.DOM.HTMLElement first_visible_email_sibling =
|
||||
(WebKit.DOM.HTMLElement) first_visible_email.previous_sibling;
|
||||
if (first_visible_email_sibling != null) {
|
||||
web_view.scroll_to_element(first_visible_email_sibling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Geary.Email? get_email_from_element(WebKit.DOM.Element element) {
|
||||
// First get the email container.
|
||||
|
|
|
|||
|
|
@ -313,5 +313,9 @@ public class ConversationWebView : WebKit.WebView {
|
|||
public WebKit.DOM.HTMLDivElement create_div() throws Error {
|
||||
return get_dom_document().create_element("div") as WebKit.DOM.HTMLDivElement;
|
||||
}
|
||||
|
||||
public void scroll_to_element(WebKit.DOM.HTMLElement element) {
|
||||
get_dom_document().get_default_view().scroll(element.offset_left, element.offset_top);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue