[geary/wip/draft-management: 3/7] Infer draft status from composer's draft_id property
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/draft-management: 3/7] Infer draft status from composer's draft_id property
- Date: Fri, 2 Aug 2019 04:10:23 +0000 (UTC)
commit ab83027d6131757055cabac5a494060bd6df72ba
Author: Michael Gratton <mike vee net>
Date: Fri Aug 2 11:14:28 2019 +1000
Infer draft status from composer's draft_id property
This lets remove the `is_draft` flag from a bunch of places, simplifying
logic at a number of call sites.
src/client/application/application-controller.vala | 7 ++-----
src/client/components/main-window.vala | 2 +-
src/client/composer/composer-widget.vala | 8 ++++++--
src/client/conversation-viewer/conversation-viewer.vala | 8 +++++---
4 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/client/application/application-controller.vala
b/src/client/application/application-controller.vala
index 627e7b67..ac79262d 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -2097,8 +2097,7 @@ public class Application.Controller : Geary.BaseObject {
if (widget.state == INLINE || widget.state == INLINE_COMPACT) {
this.main_window.conversation_viewer.do_compose_embedded(
widget,
- referred,
- is_draft
+ referred
);
} else {
this.main_window.show_composer(widget);
@@ -2109,7 +2108,6 @@ public class Application.Controller : Geary.BaseObject {
widget,
referred,
quote,
- is_draft,
this.cancellable_folder
);
}
@@ -2118,7 +2116,6 @@ public class Application.Controller : Geary.BaseObject {
ComposerWidget widget,
Geary.Email? referred = null,
string? quote = null,
- bool is_draft = false,
GLib.Cancellable? cancellable) {
Geary.Email? full = null;
if (referred != null) {
@@ -2136,7 +2133,7 @@ public class Application.Controller : Geary.BaseObject {
}
}
}
- yield widget.load(full, quote, is_draft, cancellable);
+ yield widget.load(full, quote, cancellable);
widget.set_focus();
}
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index b3de97cc..23f00a9e 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -223,7 +223,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
composer.to = to.to_full_display();
controller.add_composer(composer);
show_composer(composer);
- composer.load.begin(null, null, false, null);
+ composer.load.begin(null, null, null);
}
/** Displays a composer in the window if possible, else in a new window. */
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 48ddbcba..fbcb6689 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -633,10 +633,14 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
*/
public async void load(Geary.Email? referred = null,
string? quote = null,
- bool is_referred_draft = false,
GLib.Cancellable? cancellable) {
- this.last_quote = quote;
+ bool is_referred_draft = (
+ referred != null &&
+ this.draft_id != null &&
+ referred.id.equal_to(this.draft_id)
+ );
string referred_quote = "";
+ this.last_quote = quote;
if (referred != null) {
referred_quote = fill_in_from_referred(referred, quote);
if (is_referred_draft ||
diff --git a/src/client/conversation-viewer/conversation-viewer.vala
b/src/client/conversation-viewer/conversation-viewer.vala
index cce1b14d..dd3efb89 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -162,8 +162,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
* Puts the view into composer mode, showing an embedded composer.
*/
public void do_compose_embedded(ComposerWidget composer,
- Geary.Email? referred,
- bool is_draft) {
+ Geary.Email? referred) {
this.current_composer = composer;
ComposerEmbed embed = new ComposerEmbed(
referred,
@@ -178,7 +177,10 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
conversation_scroller.kinetic_scrolling = false;
if (this.current_list != null) {
- this.current_list.add_embedded_composer(embed, is_draft);
+ this.current_list.add_embedded_composer(
+ embed,
+ composer.draft_id != null
+ );
}
conversation_scroller.kinetic_scrolling = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]