diff --git a/src/conversation-list/conversation-list-model.vala b/src/conversation-list/conversation-list-model.vala
index d50f983..dc87912 100644
--- a/src/conversation-list/conversation-list-model.vala
+++ b/src/conversation-list/conversation-list-model.vala
@@ -15,8 +15,23 @@ public class ConversationListModel : Object, ListModel
return (int)(b.date - a.date);
});
- Repository.get_instance().conversations_updated.connect(load_conversations);
- Repository.get_instance().messages_updated.connect(load_conversations);
+ weak ConversationListModel self = this;
+ Repository.get_instance().conversations_updated.connect(() => {
+ self.load_conversations();
+ });
+
+ Repository.get_instance().messages_updated.connect((conversation_guid) => {
+ self.load_conversations();
+ });
+
+ Repository.get_instance().reconnected.connect(() => {
+ // Trigger a sync-list to get the latest conversations
+ try {
+ Repository.get_instance().sync_conversation_list();
+ } catch (GLib.Error e) {
+ warning("Failed to sync conversation list: %s", e.message);
+ }
+ });
}
public Conversation? get_conversation(string guid) {
diff --git a/src/conversation-list/conversation-list-view.vala b/src/conversation-list/conversation-list-view.vala
index 739a1d8..7cdf069 100644
--- a/src/conversation-list/conversation-list-view.vala
+++ b/src/conversation-list/conversation-list-view.vala
@@ -44,7 +44,7 @@ public class ConversationListView : Adw.Bin
var app_menu = new Menu ();
var section = new Menu ();
- section.append ("Refresh", "list.refresh");
+ section.append ("Manual Sync", "list.refresh");
section.append ("Settings...", "win.settings");
app_menu.append_section (null, section);
@@ -54,8 +54,10 @@ public class ConversationListView : Adw.Bin
var refresh_action = new SimpleAction("refresh", null);
refresh_action.activate.connect (() => {
- if (conversation_model != null) {
- conversation_model.load_conversations ();
+ try {
+ Repository.get_instance().sync_conversation_list();
+ } catch (GLib.Error e) {
+ warning("Failed to sync conversation list: %s", e.message);
}
});
diff --git a/src/service/interface/dbusservice.vala b/src/service/interface/dbusservice.vala
index f352da2..63879cf 100644
--- a/src/service/interface/dbusservice.vala
+++ b/src/service/interface/dbusservice.vala
@@ -53,6 +53,9 @@ namespace DBusService {
[DBus (name = "MessagesUpdated")]
public signal void messages_updated(string conversation_id);
+ [DBus (name = "UpdateStreamReconnected")]
+ public signal void update_stream_reconnected();
+
[DBus (name = "GetAttachmentInfo")]
public abstract RepositoryAttachmentInfoStruct get_attachment_info(string attachment_id) throws DBusError, IOError;
diff --git a/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml b/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml
index 8e93ca5..a0898e3 100644
--- a/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml
+++ b/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml
@@ -103,6 +103,11 @@
value="Emitted when the list of messages is updated."/>
+
+
+
+
diff --git a/src/service/repository.vala b/src/service/repository.vala
index f89f757..59aeab1 100644
--- a/src/service/repository.vala
+++ b/src/service/repository.vala
@@ -6,6 +6,7 @@ public class Repository : DBusServiceProxy {
public signal void messages_updated(string conversation_guid);
public signal void attachment_downloaded(string attachment_guid);
public signal void attachment_uploaded(string upload_guid, string attachment_guid);
+ public signal void reconnected();
public static Repository get_instance() {
if (instance == null) {
@@ -46,11 +47,24 @@ public class Repository : DBusServiceProxy {
attachment_uploaded(upload_guid, attachment_guid);
});
+ this.dbus_repository.update_stream_reconnected.connect(() => {
+ reconnected();
+ });
+
conversations_updated();
+ reconnected();
} catch (GLib.Error e) {
warning("Failed to connect to repository: %s", e.message);
}
}
+
+ public void sync_conversation_list() throws DBusServiceProxyError, GLib.Error {
+ if (dbus_repository == null) {
+ throw new DBusServiceProxyError.NOT_CONNECTED("Repository not connected");
+ }
+
+ dbus_repository.sync_conversation_list();
+ }
public Conversation[] get_conversations(int limit = 200) throws DBusServiceProxyError, GLib.Error {
if (dbus_repository == null) {
diff --git a/src/transcript/message-list-model.vala b/src/transcript/message-list-model.vala
index 25c58fb..7bf111e 100644
--- a/src/transcript/message-list-model.vala
+++ b/src/transcript/message-list-model.vala
@@ -34,7 +34,15 @@ public class MessageListModel : Object, ListModel
public void watch_updates() {
if (this.handler_id == 0) {
- this.handler_id = Repository.get_instance().messages_updated.connect(got_messages_updated);
+ weak MessageListModel self = this;
+ this.handler_id = Repository.get_instance().messages_updated.connect((conversation_guid) => {
+ self.got_messages_updated(conversation_guid);
+ });
+
+ this.handler_id = Repository.get_instance().reconnected.connect(() => {
+ // On reconnect, reload the messages that we're looking at now.
+ self.load_messages();
+ });
}
}