aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorbobufa <bobufa@users.noreply.github.com>2018-07-16 21:26:39 +0200
committerbobufa <bobufa@users.noreply.github.com>2018-08-13 22:39:07 +0200
commit2e2a9a239000509488f1a369ea4eaf4cdda9c0b1 (patch)
tree8c37f732a3f6b7345a19a8e17e151991ee72d0b6 /main/src/ui
parent61915ca56617e8f45ae8bd85cb87f0b8a9a895b0 (diff)
downloaddino-2e2a9a239000509488f1a369ea4eaf4cdda9c0b1.tar.gz
dino-2e2a9a239000509488f1a369ea4eaf4cdda9c0b1.zip
accumulate conversation content in meta db table
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/conversation_summary/content_populator.vala35
-rw-r--r--main/src/ui/conversation_summary/conversation_view.vala8
2 files changed, 23 insertions, 20 deletions
diff --git a/main/src/ui/conversation_summary/content_populator.vala b/main/src/ui/conversation_summary/content_populator.vala
index cec54c7b..9ebb9159 100644
--- a/main/src/ui/conversation_summary/content_populator.vala
+++ b/main/src/ui/conversation_summary/content_populator.vala
@@ -19,13 +19,14 @@ public class ContentProvider : ContentItemCollection, Object {
}
public void init(Plugins.ConversationItemCollection item_collection, Conversation conversation, Plugins.WidgetType type) {
+ if (current_conversation != null) {
+ stream_interactor.get_module(ContentItemStore.IDENTITY).uninit(current_conversation, this);
+ }
current_conversation = conversation;
this.item_collection = item_collection;
- stream_interactor.get_module(ContentItemAccumulator.IDENTITY).init(conversation, this);
+ stream_interactor.get_module(ContentItemStore.IDENTITY).init(conversation, this);
}
- public void close(Conversation conversation) { }
-
public void insert_item(ContentItem item) {
item_collection.insert_item(new ContentMetaItem(item, widget_factory));
}
@@ -34,7 +35,7 @@ public class ContentProvider : ContentItemCollection, Object {
public Gee.List<ContentMetaItem> populate_latest(Conversation conversation, int n) {
- Gee.List<ContentItem> items = stream_interactor.get_module(ContentItemAccumulator.IDENTITY).populate_latest(this, conversation, n);
+ Gee.List<ContentItem> items = stream_interactor.get_module(ContentItemStore.IDENTITY).get_latest(conversation, n);
Gee.List<ContentMetaItem> ret = new ArrayList<ContentMetaItem>();
foreach (ContentItem item in items) {
ret.add(new ContentMetaItem(item, widget_factory));
@@ -42,29 +43,27 @@ public class ContentProvider : ContentItemCollection, Object {
return ret;
}
- public Gee.List<ContentMetaItem> populate_before(Conversation conversation, Plugins.MetaConversationItem before_item, int n) {
+ public Gee.List<ContentMetaItem> populate_before(Conversation conversation, ContentItem before_item, int n) {
Gee.List<ContentMetaItem> ret = new ArrayList<ContentMetaItem>();
- ContentMetaItem? content_meta_item = before_item as ContentMetaItem;
- if (content_meta_item != null) {
- Gee.List<ContentItem> items = stream_interactor.get_module(ContentItemAccumulator.IDENTITY).populate_before(this, conversation, content_meta_item.content_item, n);
- foreach (ContentItem item in items) {
- ret.add(new ContentMetaItem(item, widget_factory));
- }
+ Gee.List<ContentItem> items = stream_interactor.get_module(ContentItemStore.IDENTITY).get_before(conversation, before_item, n);
+ foreach (ContentItem item in items) {
+ ret.add(new ContentMetaItem(item, widget_factory));
}
return ret;
}
- public Gee.List<ContentMetaItem> populate_after(Conversation conversation, Plugins.MetaConversationItem before_item, int n) {
+ public Gee.List<ContentMetaItem> populate_after(Conversation conversation, ContentItem after_item, int n) {
Gee.List<ContentMetaItem> ret = new ArrayList<ContentMetaItem>();
- ContentMetaItem? content_meta_item = before_item as ContentMetaItem;
- if (content_meta_item != null) {
- Gee.List<ContentItem> items = stream_interactor.get_module(ContentItemAccumulator.IDENTITY).populate_after(this, conversation, content_meta_item.content_item, n);
- foreach (ContentItem item in items) {
- ret.add(new ContentMetaItem(item, widget_factory));
- }
+ Gee.List<ContentItem> items = stream_interactor.get_module(ContentItemStore.IDENTITY).get_after(conversation, after_item, n);
+ foreach (ContentItem item in items) {
+ ret.add(new ContentMetaItem(item, widget_factory));
}
return ret;
}
+
+ public ContentMetaItem get_content_meta_item(ContentItem content_item) {
+ return new ContentMetaItem(content_item, widget_factory);
+ }
}
public class ContentMetaItem : Plugins.MetaConversationItem {
diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala
index 870b6ee3..a1863cf4 100644
--- a/main/src/ui/conversation_summary/conversation_view.vala
+++ b/main/src/ui/conversation_summary/conversation_view.vala
@@ -270,9 +270,13 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
was_value = scrolled.vadjustment.value;
if (!reloading_mutex.trylock()) return;
if (meta_items.size > 0) {
- Gee.List<ContentMetaItem> items = content_populator.populate_before(conversation, content_items.first(), 20);
+ Gee.List<ContentMetaItem> items = content_populator.populate_before(conversation, (content_items.first() as ContentMetaItem).content_item, 20);
foreach (ContentMetaItem item in items) {
do_insert_item(item);
+ if (content_items.size > 50) {
+ do_remove_item(content_items.last());
+ at_current_content = false;
+ }
}
} else {
reloading_mutex.unlock();
@@ -286,7 +290,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
ContentMetaItem b = a as ContentMetaItem;
MessageItem c = b.content_item as MessageItem;
}
- Gee.List<ContentMetaItem> items = content_populator.populate_after(conversation, content_items.last(), 20);
+ Gee.List<ContentMetaItem> items = content_populator.populate_after(conversation, (content_items.last() as ContentMetaItem).content_item, 20);
ContentMetaItem b = content_items.last() as ContentMetaItem;
MessageItem c = b.content_item as MessageItem;