aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/roster_manager.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-05-24 17:28:39 +0200
committerfiaxh <git@mx.ax.lt>2017-05-24 17:29:17 +0200
commit142257a544b36e60b738e55e5f9f096f1169c389 (patch)
tree0e02590f59615689b4c77dbe5b23e51fd04bb96f /libdino/src/service/roster_manager.vala
parentbcb96909c9b53c2ca5287433f2fef103b0ddf317 (diff)
downloaddino-142257a544b36e60b738e55e5f9f096f1169c389.tar.gz
dino-142257a544b36e60b738e55e5f9f096f1169c389.zip
fixup bcb9690 (Roster versioning)
Diffstat (limited to 'libdino/src/service/roster_manager.vala')
-rw-r--r--libdino/src/service/roster_manager.vala20
1 files changed, 3 insertions, 17 deletions
diff --git a/libdino/src/service/roster_manager.vala b/libdino/src/service/roster_manager.vala
index 91da7579..e17c24e3 100644
--- a/libdino/src/service/roster_manager.vala
+++ b/libdino/src/service/roster_manager.vala
@@ -72,14 +72,12 @@ public class RosterStoreImpl : Roster.Storage, Object {
private Account account;
private Database db;
- private string version = "";
private HashMap<string, Roster.Item> items = new HashMap<string, Roster.Item>();
public class RosterStoreImpl(Account account, Database db) {
this.account = account;
this.db = db;
- version = db_get_roster_version() ?? "";
foreach (Qlite.Row row in db.roster.select().with(db.roster.account_id, "=", account.id)) {
Roster.Item item = new Roster.Item();
item.jid = row[db.roster.jid];
@@ -90,7 +88,7 @@ public class RosterStoreImpl : Roster.Storage, Object {
}
public string? get_roster_version() {
- return version;
+ return account.roster_version;
}
public Collection<Roster.Item> get_roster() {
@@ -102,11 +100,7 @@ public class RosterStoreImpl : Roster.Storage, Object {
}
public void set_roster_version(string version) {
- db.account_key_value.insert().or("REPLACE")
- .value(db.account_key_value.account_id, account.id)
- .value(db.account_key_value.key, "roster_version")
- .value(db.account_key_value.value, version)
- .perform();
+ account.roster_version = version;
}
public void set_roster(Collection<Roster.Item> items) {
@@ -130,15 +124,7 @@ public class RosterStoreImpl : Roster.Storage, Object {
items.unset(item.jid);
db.roster.delete()
.with(db.roster.account_id, "=", account.id)
- .with(db.roster.jid, "=", item.jid);
- }
-
- private string? db_get_roster_version() {
- Qlite.Row? row = db.account_key_value.select()
- .with(db.account_key_value.account_id, "=", account.id)
- .with(db.account_key_value.key, "=", "roster_version").iterator().get_next();
- if (row != null) return row[db.account_key_value.value];
- return null;
+ .with(db.roster.jid, "=", item.jid).perform();
}
}