Change conversation (un)read marking

This commit is contained in:
fiaxh 2017-09-19 23:23:12 +02:00
parent 8fdb38b99b
commit 7430efee57
3 changed files with 5 additions and 20 deletions

View file

@ -11,8 +11,6 @@ public class ChatInteraction : StreamInteractionModule, Object {
public signal void focused_in(Conversation conversation); public signal void focused_in(Conversation conversation);
public signal void focused_out(Conversation conversation); public signal void focused_out(Conversation conversation);
public signal void conversation_read(Conversation conversation);
public signal void conversation_unread(Conversation conversation);
private StreamInteractor stream_interactor; private StreamInteractor stream_interactor;
private Conversation? selected_conversation; private Conversation? selected_conversation;
@ -80,7 +78,6 @@ public class ChatInteraction : StreamInteractionModule, Object {
focus_in = true; focus_in = true;
if (conversation == null) return; if (conversation == null) return;
focused_in(selected_conversation); focused_in(selected_conversation);
conversation_read(selected_conversation);
check_send_read(); check_send_read();
selected_conversation.read_up_to = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation); selected_conversation.read_up_to = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation);
} }
@ -137,7 +134,6 @@ public class ChatInteraction : StreamInteractionModule, Object {
send_chat_marker(conversation, message, Xep.ChatMarkers.MARKER_DISPLAYED); send_chat_marker(conversation, message, Xep.ChatMarkers.MARKER_DISPLAYED);
} else { } else {
send_chat_marker(conversation, message, Xep.ChatMarkers.MARKER_RECEIVED); send_chat_marker(conversation, message, Xep.ChatMarkers.MARKER_RECEIVED);
conversation_unread(conversation);
} }
} }

View file

@ -57,14 +57,7 @@ public abstract class ConversationRow : ListBoxRow {
last_message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation) ?? m; last_message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation) ?? m;
update_message_label(); update_message_label();
update_time_label(); update_time_label();
} update_read();
public void mark_read() {
update_read(true);
}
public void mark_unread() {
update_read(false);
} }
public virtual void on_show_received(Show presence) { public virtual void on_show_received(Show presence) {
@ -103,8 +96,10 @@ public abstract class ConversationRow : ListBoxRow {
} }
} }
protected void update_read(bool read) { protected void update_read() {
this.read = read; bool read_was = read;
read = last_message == null || (conversation.read_up_to != null && last_message.equals(conversation.read_up_to));
if (read == read_was) return;
if (read) { if (read) {
name_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD))); name_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));
time_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD))); time_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));

View file

@ -22,12 +22,6 @@ public class List : ListBox {
set_header_func(header); set_header_func(header);
set_sort_func(sort); set_sort_func(sort);
stream_interactor.get_module(ChatInteraction.IDENTITY).conversation_read.connect((conversation) => {
Idle.add(() => { if (rows.has_key(conversation)) rows[conversation].mark_read(); return false; });
});
stream_interactor.get_module(ChatInteraction.IDENTITY).conversation_unread.connect((conversation) => {
Idle.add(() => { if (rows.has_key(conversation)) rows[conversation].mark_unread(); return false; });
});
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect((conversation) => { stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect((conversation) => {
Idle.add(() => { add_conversation(conversation); return false; }); Idle.add(() => { add_conversation(conversation); return false; });
}); });