aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/content_item_store.vala
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src/service/content_item_store.vala')
-rw-r--r--libdino/src/service/content_item_store.vala17
1 files changed, 15 insertions, 2 deletions
diff --git a/libdino/src/service/content_item_store.vala b/libdino/src/service/content_item_store.vala
index 1ea0275e..640c3fda 100644
--- a/libdino/src/service/content_item_store.vala
+++ b/libdino/src/service/content_item_store.vala
@@ -40,7 +40,7 @@ public class ContentItemStore : StreamInteractionModule, Object {
}
public Gee.List<ContentItem> get_items_from_query(QueryBuilder select, Conversation conversation) {
- Gee.TreeSet<ContentItem> items = new Gee.TreeSet<ContentItem>(ContentItem.compare);
+ Gee.TreeSet<ContentItem> items = new Gee.TreeSet<ContentItem>(ContentItem.compare_func);
foreach (var row in select) {
int provider = row[db.content_item.content_type];
@@ -113,6 +113,15 @@ public class ContentItemStore : StreamInteractionModule, Object {
return item.size > 0 ? item[0] : null;
}
+ public ContentItem? get_item_by_id(Conversation conversation, int id) {
+ QueryBuilder select = db.content_item.select()
+ .with(db.content_item.id, "=", id);
+
+ Gee.List<ContentItem> item = get_items_from_query(select, conversation);
+
+ return item.size > 0 ? item[0] : null;
+ }
+
public ContentItem? get_latest(Conversation conversation) {
Gee.List<ContentItem> items = get_n_latest(conversation, 1);
if (items.size > 0) {
@@ -246,7 +255,11 @@ public abstract class ContentItem : Object {
this.mark = mark;
}
- public static int compare(ContentItem a, ContentItem b) {
+ public int compare(ContentItem c) {
+ return compare_func(this, c);
+ }
+
+ public static int compare_func(ContentItem a, ContentItem b) {
int res = a.sort_time.compare(b.sort_time);
if (res == 0) {
res = a.display_time.compare(b.display_time);