diff options
Diffstat (limited to 'main/src/ui')
-rw-r--r-- | main/src/ui/conversation_summary/content_populator.vala | 35 | ||||
-rw-r--r-- | main/src/ui/conversation_summary/conversation_view.vala | 8 |
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; |