Skip to content

Commit b7a0eed

Browse files
committed
Avoid calling find_message twice, just reuse it
1 parent 379691e commit b7a0eed

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/message_actions.vala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ namespace Dc {
5555
});
5656
vbox.append (pin_btn);
5757

58+
var msg = find_message (message_store, msg_id);
59+
5860
/* Save file (for messages with attachments) */
59-
var m_save = find_message (message_store, msg_id);
60-
if (m_save != null && m_save.file_path != null &&
61-
m_save.file_path.length > 0) {
62-
string fpath = m_save.file_path;
63-
string? fname = m_save.file_name;
61+
if (msg != null && msg.file_path != null &&
62+
msg.file_path.length > 0) {
63+
string fpath = msg.file_path;
64+
string? fname = msg.file_name;
6465
var save_btn = new Gtk.Button.with_label ("Save file");
6566
save_btn.add_css_class ("flat");
6667
save_btn.clicked.connect (() => {
@@ -73,10 +74,9 @@ namespace Dc {
7374
if (is_outgoing) {
7475
/* Allow editing only if the message has text */
7576
bool has_text = false;
76-
var m_edit = find_message (message_store, msg_id);
77-
if (m_edit != null) {
78-
has_text = (m_edit.text != null &&
79-
m_edit.text.strip ().length > 0);
77+
if (msg != null) {
78+
has_text = (msg.text != null &&
79+
msg.text.strip ().length > 0);
8080
}
8181
if (has_text) {
8282
var edit_btn = new Gtk.Button.with_label ("Edit");

0 commit comments

Comments
 (0)