aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_content_view
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/conversation_content_view')
-rw-r--r--main/src/ui/conversation_content_view/chat_state_populator.vala2
-rw-r--r--main/src/ui/conversation_content_view/content_populator.vala6
-rw-r--r--main/src/ui/conversation_content_view/conversation_item_skeleton.vala6
-rw-r--r--main/src/ui/conversation_content_view/conversation_view.vala25
-rw-r--r--main/src/ui/conversation_content_view/date_separator_populator.vala6
-rw-r--r--main/src/ui/conversation_content_view/message_widget.vala4
6 files changed, 21 insertions, 28 deletions
diff --git a/main/src/ui/conversation_content_view/chat_state_populator.vala b/main/src/ui/conversation_content_view/chat_state_populator.vala
index 9b782959..247c83fe 100644
--- a/main/src/ui/conversation_content_view/chat_state_populator.vala
+++ b/main/src/ui/conversation_content_view/chat_state_populator.vala
@@ -62,7 +62,7 @@ class ChatStatePopulator : Plugins.ConversationItemPopulator, Plugins.Conversati
}
private class MetaChatStateItem : Plugins.MetaConversationItem {
- public override DateTime sort_time { get; set; default=new DateTime.now_utc().add_years(10); }
+ public override DateTime time { get; set; default=new DateTime.now_utc().add_years(10); }
private StreamInteractor stream_interactor;
private Conversation conversation;
diff --git a/main/src/ui/conversation_content_view/content_populator.vala b/main/src/ui/conversation_content_view/content_populator.vala
index 48a9e12a..97f15bf9 100644
--- a/main/src/ui/conversation_content_view/content_populator.vala
+++ b/main/src/ui/conversation_content_view/content_populator.vala
@@ -79,10 +79,8 @@ public abstract class ContentMetaItem : Plugins.MetaConversationItem {
protected ContentMetaItem(ContentItem content_item) {
this.jid = content_item.jid;
- this.sort_time = content_item.sort_time;
- this.seccondary_sort_indicator = (long) content_item.display_time.to_unix();
- this.tertiary_sort_indicator = content_item.id;
- this.display_time = content_item.display_time;
+ this.time = content_item.time;
+ this.secondary_sort_indicator = content_item.id;
this.encryption = content_item.encryption;
this.mark = content_item.mark;
diff --git a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
index 80aa4fd6..c3db09e0 100644
--- a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
+++ b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
@@ -146,7 +146,7 @@ public class ItemMetaDataHeader : Box {
this.add(received_image);
- if (item.display_time != null) {
+ if (item.time != null) {
update_time();
}
@@ -170,7 +170,7 @@ public class ItemMetaDataHeader : Box {
}
private void update_time() {
- time_label.label = get_relative_time(item.display_time.to_local()).to_string();
+ time_label.label = get_relative_time(item.time.to_local()).to_string();
time_update_timeout = Timeout.add_seconds((int) get_next_time_change(), () => {
if (this.parent == null) return false;
@@ -226,7 +226,7 @@ public class ItemMetaDataHeader : Box {
private int get_next_time_change() {
DateTime now = new DateTime.now_local();
- DateTime item_time = item.display_time;
+ DateTime item_time = item.time;
TimeSpan timespan = now.difference(item_time);
if (timespan < 10 * TimeSpan.MINUTE) {
diff --git a/main/src/ui/conversation_content_view/conversation_view.vala b/main/src/ui/conversation_content_view/conversation_view.vala
index e46cd71f..70b16bd9 100644
--- a/main/src/ui/conversation_content_view/conversation_view.vala
+++ b/main/src/ui/conversation_content_view/conversation_view.vala
@@ -293,8 +293,8 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
public void insert_item(Plugins.MetaConversationItem item) {
if (meta_items.size > 0) {
- bool after_last = meta_items.last().sort_time.compare(item.sort_time) <= 0;
- bool within_range = meta_items.last().sort_time.compare(item.sort_time) > 0 && meta_items.first().sort_time.compare(item.sort_time) < 0;
+ bool after_last = meta_items.last().time.compare(item.time) <= 0;
+ bool within_range = meta_items.last().time.compare(item.time) > 0 && meta_items.first().time.compare(item.time) < 0;
bool accept = within_range || (at_current_content && after_last);
if (!accept) {
return;
@@ -398,11 +398,11 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
Dino.Application app = Dino.Application.get_default();
if (item_skeletons.size == 1) {
foreach (Plugins.ConversationAdditionPopulator populator in app.plugin_registry.conversation_addition_populators) {
- populator.populate_timespan(conversation, item.sort_time, new DateTime.now_utc());
+ populator.populate_timespan(conversation, item.time, new DateTime.now_utc());
}
} else {
foreach (Plugins.ConversationAdditionPopulator populator in app.plugin_registry.conversation_addition_populators) {
- populator.populate_timespan(conversation, item.sort_time, meta_items.higher(item).sort_time);
+ populator.populate_timespan(conversation, item.time, meta_items.higher(item).time);
}
}
}
@@ -410,8 +410,8 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
}
private bool can_merge(Plugins.MetaConversationItem upper_item /*more recent, displayed below*/, Plugins.MetaConversationItem lower_item /*less recent, displayed above*/) {
- return upper_item.display_time != null && lower_item.display_time != null &&
- upper_item.display_time.difference(lower_item.display_time) < TimeSpan.MINUTE &&
+ return upper_item.time != null && lower_item.time != null &&
+ upper_item.time.difference(lower_item.time) < TimeSpan.MINUTE &&
upper_item.jid != null && lower_item.jid != null &&
upper_item.jid.equals(lower_item.jid) &&
upper_item.encryption == lower_item.encryption &&
@@ -470,15 +470,10 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
}
private static int compare_meta_items(Plugins.MetaConversationItem a, Plugins.MetaConversationItem b) {
- int cmp1 = a.sort_time.compare(b.sort_time);
- if (cmp1 == 0) {
- double cmp2 = a.seccondary_sort_indicator - b.seccondary_sort_indicator;
- if (cmp2 == 0) {
- return (int) (a.tertiary_sort_indicator - b.tertiary_sort_indicator);
- }
- return (int) cmp2;
- }
- return cmp1;
+ int cmp1 = a.time.compare(b.time);
+ if (cmp1 != 0) return cmp1;
+
+ return a.secondary_sort_indicator - b.secondary_sort_indicator;
}
private void clear() {
diff --git a/main/src/ui/conversation_content_view/date_separator_populator.vala b/main/src/ui/conversation_content_view/date_separator_populator.vala
index ff3b962d..5f6838e5 100644
--- a/main/src/ui/conversation_content_view/date_separator_populator.vala
+++ b/main/src/ui/conversation_content_view/date_separator_populator.vala
@@ -38,7 +38,7 @@ class DateSeparatorPopulator : Plugins.ConversationItemPopulator, Plugins.Conver
private void on_inserted_item(Plugins.MetaConversationItem item) {
if (!(item is ContentMetaItem)) return;
- DateTime time = item.sort_time.to_local();
+ DateTime time = item.time.to_local();
DateTime msg_date = new DateTime.local(time.get_year(), time.get_month(), time.get_day_of_month(), 0, 0, 0);
if (!insert_times.contains(msg_date)) {
if (insert_times.lower(msg_date) != null) {
@@ -52,13 +52,13 @@ class DateSeparatorPopulator : Plugins.ConversationItemPopulator, Plugins.Conver
}
public class MetaDateItem : Plugins.MetaConversationItem {
- public override DateTime sort_time { get; set; }
+ public override DateTime time { get; set; }
private DateTime date;
public MetaDateItem(DateTime date) {
this.date = date;
- this.sort_time = date;
+ this.time = date;
}
public override Object? get_widget(Plugins.WidgetType widget_type) {
diff --git a/main/src/ui/conversation_content_view/message_widget.vala b/main/src/ui/conversation_content_view/message_widget.vala
index 05661e56..44584709 100644
--- a/main/src/ui/conversation_content_view/message_widget.vala
+++ b/main/src/ui/conversation_content_view/message_widget.vala
@@ -190,7 +190,7 @@ public class MessageItemWidget : SizeRequestBin {
// Append "pending..." iff message has not been sent yet
if (message.direction == Message.DIRECTION_SENT && (message.marked == Message.Marked.SENDING || message.marked == Message.Marked.UNSENT)) {
- if (message.local_time.compare(new DateTime.now_utc().add_seconds(-10)) < 0) {
+ if (message.time.compare(new DateTime.now_utc().add_seconds(-10)) < 0) {
markup_text += " <span size='small' color='%s'>%s</span>".printf(gray_color, "pending…");
// Update the label as soon as the sent state changes
@@ -201,7 +201,7 @@ public class MessageItemWidget : SizeRequestBin {
update_label();
});
} else {
- int time_diff = (- (int) message.local_time.difference(new DateTime.now_utc()) / 1000);
+ int time_diff = (- (int) message.time.difference(new DateTime.now_utc()) / 1000);
Timeout.add(10000 - time_diff, () => {
update_label();
return false;