Fix various date/time stamps not updated or wrong time zone
This commit is contained in:
parent
32ae87a3c4
commit
116682e311
|
@ -175,7 +175,7 @@ namespace Dino.Ui {
|
||||||
case Call.State.ENDED:
|
case Call.State.ENDED:
|
||||||
image.set_from_icon_name("dino-phone-hangup-symbolic");
|
image.set_from_icon_name("dino-phone-hangup-symbolic");
|
||||||
title_label.label = _("Call ended");
|
title_label.label = _("Call ended");
|
||||||
string formated_end = Util.format_time(call.end_time, _("%H∶%M"), _("%l∶%M %p"));
|
string formated_end = Util.format_time(call.end_time.to_local(), _("%H∶%M"), _("%l∶%M %p"));
|
||||||
string duration = get_duration_string(call.end_time.difference(call.local_time));
|
string duration = get_duration_string(call.end_time.difference(call.local_time));
|
||||||
subtitle_label.label = _("Ended at %s").printf(formated_end) +
|
subtitle_label.label = _("Ended at %s").printf(formated_end) +
|
||||||
" · " +
|
" · " +
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
|
||||||
private void update_time() {
|
private void update_time() {
|
||||||
time_label.label = get_relative_time(item.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(), () => {
|
time_update_timeout = Timeout.add_seconds((int) get_next_time_change(item.time), () => {
|
||||||
if (this.main_grid.parent == null) return false;
|
if (this.main_grid.parent == null) return false;
|
||||||
update_time();
|
update_time();
|
||||||
return false;
|
return false;
|
||||||
|
@ -206,16 +206,15 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int get_next_time_change() {
|
public static int get_next_time_change(DateTime datetime) {
|
||||||
DateTime now = new DateTime.now_local();
|
DateTime now = new DateTime.now_local();
|
||||||
DateTime item_time = item.time;
|
TimeSpan timespan = now.difference(datetime);
|
||||||
TimeSpan timespan = now.difference(item_time);
|
|
||||||
|
|
||||||
if (timespan < 10 * TimeSpan.MINUTE) {
|
if (timespan < 10 * TimeSpan.MINUTE) {
|
||||||
if (now.get_second() < item_time.get_second()) {
|
if (now.get_second() < datetime.get_second()) {
|
||||||
return item_time.get_second() - now.get_second();
|
return datetime.get_second() - now.get_second();
|
||||||
} else {
|
} else {
|
||||||
return 60 - (now.get_second() - item_time.get_second());
|
return 60 - (now.get_second() - datetime.get_second());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return (23 - now.get_hour()) * 3600 + (59 - now.get_minute()) * 60 + (59 - now.get_second());
|
return (23 - now.get_hour()) * 3600 + (59 - now.get_minute()) * 60 + (59 - now.get_second());
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Dino.Ui.Quote {
|
||||||
|
|
||||||
public string display_name { get; set; }
|
public string display_name { get; set; }
|
||||||
public string message { get; set; }
|
public string message { get; set; }
|
||||||
|
public string display_time { get; set; }
|
||||||
public DateTime message_time { get; set; }
|
public DateTime message_time { get; set; }
|
||||||
|
|
||||||
public StreamInteractor stream_interactor { get; set; }
|
public StreamInteractor stream_interactor { get; set; }
|
||||||
|
@ -21,6 +22,8 @@ namespace Dino.Ui.Quote {
|
||||||
|
|
||||||
public bool can_abort { get; set; default=false; }
|
public bool can_abort { get; set; default=false; }
|
||||||
|
|
||||||
|
private uint display_time_timeout;
|
||||||
|
|
||||||
public Model.from_content_item(ContentItem content_item, Conversation conversation, StreamInteractor stream_interactor) {
|
public Model.from_content_item(ContentItem content_item, Conversation conversation, StreamInteractor stream_interactor) {
|
||||||
this.display_name = Util.get_participant_display_name(stream_interactor, conversation, content_item.jid, true);
|
this.display_name = Util.get_participant_display_name(stream_interactor, conversation, content_item.jid, true);
|
||||||
if (content_item.type_ == MessageItem.TYPE) {
|
if (content_item.type_ == MessageItem.TYPE) {
|
||||||
|
@ -31,11 +34,29 @@ namespace Dino.Ui.Quote {
|
||||||
this.message = _("File") + ": " + file_transfer.file_name;
|
this.message = _("File") + ": " + file_transfer.file_name;
|
||||||
}
|
}
|
||||||
this.message_time = content_item.time;
|
this.message_time = content_item.time;
|
||||||
|
update_display_time();
|
||||||
|
|
||||||
this.stream_interactor = stream_interactor;
|
this.stream_interactor = stream_interactor;
|
||||||
this.conversation = conversation;
|
this.conversation = conversation;
|
||||||
this.author_jid = content_item.jid;
|
this.author_jid = content_item.jid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void update_display_time() {
|
||||||
|
this.display_time = ConversationItemSkeleton.get_relative_time(message_time.to_local());
|
||||||
|
display_time_timeout = Timeout.add_seconds((int) ConversationItemSkeleton.get_next_time_change(message_time), () => {
|
||||||
|
if (display_time_timeout != 0) update_display_time();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void dispose() {
|
||||||
|
base.dispose();
|
||||||
|
|
||||||
|
if (display_time_timeout != 0) {
|
||||||
|
Source.remove(display_time_timeout);
|
||||||
|
display_time_timeout = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Widget get_widget(Model model) {
|
public Widget get_widget(Model model) {
|
||||||
|
@ -48,11 +69,7 @@ namespace Dino.Ui.Quote {
|
||||||
|
|
||||||
avatar.set_conversation_participant(model.stream_interactor, model.conversation, model.author_jid);
|
avatar.set_conversation_participant(model.stream_interactor, model.conversation, model.author_jid);
|
||||||
model.bind_property("display-name", author, "label", BindingFlags.SYNC_CREATE);
|
model.bind_property("display-name", author, "label", BindingFlags.SYNC_CREATE);
|
||||||
model.bind_property("message-time", time, "label", BindingFlags.SYNC_CREATE, (_, from_value, ref to_value) => {
|
model.bind_property("display-time", time, "label", BindingFlags.SYNC_CREATE);
|
||||||
DateTime message_time = (DateTime) from_value;
|
|
||||||
to_value = ConversationItemSkeleton.get_relative_time(message_time);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
model.bind_property("message", message, "label", BindingFlags.SYNC_CREATE);
|
model.bind_property("message", message, "label", BindingFlags.SYNC_CREATE);
|
||||||
model.bind_property("can-abort", abort_button, "visible", BindingFlags.SYNC_CREATE);
|
model.bind_property("can-abort", abort_button, "visible", BindingFlags.SYNC_CREATE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue