Fix ConversationRow closing if animations are disabled
This commit is contained in:
parent
41f9827166
commit
7f21f898e0
|
@ -126,6 +126,8 @@ public class ConversationManager : StreamInteractionModule, Object {
|
|||
}
|
||||
|
||||
public void close_conversation(Conversation conversation) {
|
||||
if (!conversation.active) return;
|
||||
|
||||
conversation.active = false;
|
||||
conversation_deactivated(conversation);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,11 @@ public class MucManager : StreamInteractionModule, Object {
|
|||
stream_interactor.account_added.connect(on_account_added);
|
||||
stream_interactor.stream_negotiated.connect(on_stream_negotiated);
|
||||
stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(received_message_listener);
|
||||
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect((conversation) => {
|
||||
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
|
||||
part(conversation.account, conversation.counterpart);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async Muc.JoinResult? join(Account account, Jid jid, string? nick, string? password) {
|
||||
|
|
|
@ -71,7 +71,6 @@ public class ConversationSelector : ListBox {
|
|||
row = new ConversationSelectorRow(stream_interactor, conversation);
|
||||
rows[conversation] = row;
|
||||
add(row);
|
||||
row.closed.connect(() => { select_fallback_conversation(conversation); });
|
||||
row.main_revealer.set_reveal_child(true);
|
||||
}
|
||||
invalidate_sort();
|
||||
|
@ -91,9 +90,10 @@ public class ConversationSelector : ListBox {
|
|||
}
|
||||
}
|
||||
|
||||
private void remove_conversation(Conversation conversation) {
|
||||
private async void remove_conversation(Conversation conversation) {
|
||||
select_fallback_conversation(conversation);
|
||||
if (rows.has_key(conversation)) {
|
||||
yield rows[conversation].colapse();
|
||||
remove(rows[conversation]);
|
||||
rows.unset(conversation);
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ namespace Dino.Ui {
|
|||
[GtkTemplate (ui = "/im/dino/Dino/conversation_selector/conversation_row.ui")]
|
||||
public class ConversationSelectorRow : ListBoxRow {
|
||||
|
||||
public signal void closed();
|
||||
|
||||
[GtkChild] protected AvatarImage image;
|
||||
[GtkChild] protected Label name_label;
|
||||
[GtkChild] protected Label time_label;
|
||||
|
@ -51,9 +49,6 @@ public class ConversationSelectorRow : ListBoxRow {
|
|||
});
|
||||
break;
|
||||
case Conversation.Type.GROUPCHAT:
|
||||
closed.connect(() => {
|
||||
stream_interactor.get_module(MucManager.IDENTITY).part(conversation.account, conversation.counterpart);
|
||||
});
|
||||
stream_interactor.get_module(MucManager.IDENTITY).room_name_set.connect((account, jid, room_name) => {
|
||||
if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) {
|
||||
update_name_label();
|
||||
|
@ -93,7 +88,9 @@ public class ConversationSelectorRow : ListBoxRow {
|
|||
});
|
||||
last_content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_latest(conversation);
|
||||
|
||||
x_button.clicked.connect(close_conversation);
|
||||
x_button.clicked.connect(() => {
|
||||
stream_interactor.get_module(ConversationManager.IDENTITY).close_conversation(conversation);
|
||||
});
|
||||
image.set_conversation(stream_interactor, conversation);
|
||||
conversation.notify["read-up-to"].connect(update_read);
|
||||
|
||||
|
@ -112,6 +109,19 @@ public class ConversationSelectorRow : ListBoxRow {
|
|||
update_read();
|
||||
}
|
||||
|
||||
public async void colapse() {
|
||||
main_revealer.set_transition_type(RevealerTransitionType.SLIDE_UP);
|
||||
main_revealer.set_reveal_child(false);
|
||||
|
||||
// Animations can be diabled (=> child_revealed immediately false). Wait for completion in case they're enabled.
|
||||
if (main_revealer.child_revealed) {
|
||||
main_revealer.notify["child-revealed"].connect(() => {
|
||||
Idle.add(colapse.callback);
|
||||
});
|
||||
yield;
|
||||
}
|
||||
}
|
||||
|
||||
protected void update_name_label() {
|
||||
name_label.label = Util.get_conversation_display_name(stream_interactor, conversation);
|
||||
}
|
||||
|
@ -209,15 +219,6 @@ public class ConversationSelectorRow : ListBoxRow {
|
|||
return box;
|
||||
}
|
||||
|
||||
private void close_conversation() {
|
||||
main_revealer.set_transition_type(RevealerTransitionType.SLIDE_UP);
|
||||
main_revealer.set_reveal_child(false);
|
||||
closed();
|
||||
main_revealer.notify["child-revealed"].connect(() => {
|
||||
stream_interactor.get_module(ConversationManager.IDENTITY).close_conversation(conversation);
|
||||
});
|
||||
}
|
||||
|
||||
public override void state_flags_changed(StateFlags flags) {
|
||||
StateFlags curr_flags = get_state_flags();
|
||||
if ((curr_flags & StateFlags.PRELIGHT) != 0) {
|
||||
|
|
Loading…
Reference in a new issue