Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messaging UI: add a label to pending messages on disconnect #1427

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions src/service/ui/messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,14 @@ const Conversation = GObject.registerClass({
}

_onConnected(device) {
if (device.connected)
this.pending_box.foreach(msg => msg.destroy());
// The device has disconnected, so add a label to any pending messages
// indicating they may not have completed sending.
if (!device.connected) {
this.pending_box.foreach(pending => {
pending.sender_label.label = _('Message not sent');
pending.sender_label.visible = true;
});
}
}

_onDestroy(conversation) {
Expand Down Expand Up @@ -495,19 +501,12 @@ const Conversation = GObject.registerClass({
this.plugin.sendMessage(this.addresses, this.entry.text);

// Add a phony message in the pending box
const message = new Gtk.Label({
label: URI.linkify(this.entry.text),
halign: Gtk.Align.END,
selectable: true,
use_markup: true,
visible: true,
wrap: true,
wrap_mode: Pango.WrapMode.WORD_CHAR,
xalign: 0,
const message = new ConversationMessage(null, {
addresses: this.addresses,
date: Date.now(),
body: this.entry.text,
type: Sms.MessageBox.SENT,
});
message.get_style_context().add_class('message-out');
message.date = Date.now();
message.type = Sms.MessageBox.SENT;

// Notify to reveal the pending box
this.pending_box.add(message);
Expand Down Expand Up @@ -664,10 +663,16 @@ const Conversation = GObject.registerClass({
this.list.add(row);
this.list.invalidate_headers();

// Remove the first pending message
// Check pending messages for confirmation
if (this.has_pending && message.type === Sms.MessageBox.SENT) {
this.pending_box.get_children()[0].destroy();
this.notify('has-pending');
for (const pending of this.pending_box.get_children()) {
if (message.body === pending.message.body &&
message.date >= pending.message.date) {
pending.destroy();
this.notify('has-pending');
break;
}
}
}
} catch (e) {
debug(e);
Expand Down