Only create ItemMetaDataHeader and AvatarImage once it is actually displayed
This commit is contained in:
parent
42ae68eb40
commit
909689827e
|
@ -9,10 +9,8 @@ namespace Dino.Ui.ConversationSummary {
|
||||||
|
|
||||||
public class ConversationItemSkeleton : EventBox {
|
public class ConversationItemSkeleton : EventBox {
|
||||||
|
|
||||||
private AvatarImage image = new AvatarImage() { margin_top=2, valign=Align.START, visible=true, allow_gray = false };
|
public bool show_skeleton { get; set; default=false; }
|
||||||
|
public bool last_group_item { get; set; default=true; }
|
||||||
public bool show_skeleton { get; set; }
|
|
||||||
public bool last_group_item { get; set; }
|
|
||||||
|
|
||||||
public StreamInteractor stream_interactor;
|
public StreamInteractor stream_interactor;
|
||||||
public Conversation conversation { get; set; }
|
public Conversation conversation { get; set; }
|
||||||
|
@ -20,7 +18,8 @@ public class ConversationItemSkeleton : EventBox {
|
||||||
|
|
||||||
private Box image_content_box = new Box(Orientation.HORIZONTAL, 8) { visible=true };
|
private Box image_content_box = new Box(Orientation.HORIZONTAL, 8) { visible=true };
|
||||||
private Box header_content_box = new Box(Orientation.VERTICAL, 0) { visible=true };
|
private Box header_content_box = new Box(Orientation.VERTICAL, 0) { visible=true };
|
||||||
private ItemMetaDataHeader metadata_header;
|
private ItemMetaDataHeader? metadata_header = null;
|
||||||
|
private AvatarImage? image = null;
|
||||||
|
|
||||||
public ConversationItemSkeleton(StreamInteractor stream_interactor, Conversation conversation, Plugins.MetaConversationItem item, bool initial_item) {
|
public ConversationItemSkeleton(StreamInteractor stream_interactor, Conversation conversation, Plugins.MetaConversationItem item, bool initial_item) {
|
||||||
this.stream_interactor = stream_interactor;
|
this.stream_interactor = stream_interactor;
|
||||||
|
@ -28,15 +27,6 @@ public class ConversationItemSkeleton : EventBox {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.get_style_context().add_class("message-box");
|
this.get_style_context().add_class("message-box");
|
||||||
|
|
||||||
if (item.requires_avatar) {
|
|
||||||
image.set_conversation_participant(stream_interactor, conversation, item.jid);
|
|
||||||
image_content_box.add(image);
|
|
||||||
}
|
|
||||||
if (item.requires_header) {
|
|
||||||
metadata_header = new ItemMetaDataHeader(stream_interactor, conversation, item) { visible=true };
|
|
||||||
header_content_box.add(metadata_header);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget? widget = item.get_widget(Plugins.WidgetType.GTK) as Widget;
|
Widget? widget = item.get_widget(Plugins.WidgetType.GTK) as Widget;
|
||||||
if (widget != null) {
|
if (widget != null) {
|
||||||
widget.valign = Align.END;
|
widget.valign = Align.END;
|
||||||
|
@ -58,10 +48,7 @@ public class ConversationItemSkeleton : EventBox {
|
||||||
this.notify["show-skeleton"].connect(update_margin);
|
this.notify["show-skeleton"].connect(update_margin);
|
||||||
this.notify["last-group-item"].connect(update_margin);
|
this.notify["last-group-item"].connect(update_margin);
|
||||||
|
|
||||||
this.show_skeleton = true;
|
|
||||||
this.last_group_item = true;
|
|
||||||
update_margin();
|
update_margin();
|
||||||
this.notify["show-skeleton"].connect(update_margin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update_time() {
|
public void update_time() {
|
||||||
|
@ -71,7 +58,21 @@ public class ConversationItemSkeleton : EventBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update_margin() {
|
public void update_margin() {
|
||||||
|
if (item.requires_header && show_skeleton && metadata_header == null) {
|
||||||
|
metadata_header = new ItemMetaDataHeader(stream_interactor, conversation, item) { visible=true };
|
||||||
|
header_content_box.add(metadata_header);
|
||||||
|
header_content_box.reorder_child(metadata_header, 0);
|
||||||
|
}
|
||||||
|
if (item.requires_avatar && show_skeleton && image == null) {
|
||||||
|
image = new AvatarImage() { margin_top=2, valign=Align.START, visible=true, allow_gray = false };
|
||||||
|
image.set_conversation_participant(stream_interactor, conversation, item.jid);
|
||||||
|
image_content_box.add(image);
|
||||||
|
image_content_box.reorder_child(image, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (image != null) {
|
||||||
image.visible = this.show_skeleton;
|
image.visible = this.show_skeleton;
|
||||||
|
}
|
||||||
if (metadata_header != null) {
|
if (metadata_header != null) {
|
||||||
metadata_header.visible = this.show_skeleton;
|
metadata_header.visible = this.show_skeleton;
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,7 +337,11 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
|
||||||
ConversationItemSkeleton lower_skeleton = item_item_skeletons[lower_item];
|
ConversationItemSkeleton lower_skeleton = item_item_skeletons[lower_item];
|
||||||
item_skeleton.show_skeleton = false;
|
item_skeleton.show_skeleton = false;
|
||||||
lower_skeleton.last_group_item = false;
|
lower_skeleton.last_group_item = false;
|
||||||
|
} else {
|
||||||
|
item_skeleton.show_skeleton = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
item_skeleton.show_skeleton = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins.MetaConversationItem? upper_item = meta_items.higher(item);
|
Plugins.MetaConversationItem? upper_item = meta_items.higher(item);
|
||||||
|
|
Loading…
Reference in a new issue