aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorMiquel Lionel <lionel@les-miquelots.net>2023-10-08 17:45:16 +0200
committerfiaxh <fiaxh@users.noreply.github.com>2024-08-19 11:36:17 +0200
commit8e7dedcaa62a49373c22dfc54bf1bb8b261bcb61 (patch)
tree822997b08d8cd1c2925650bf7203f928f9364c3c /main/src
parentcfb0ca2a64c1d680799ce752412b089ac075b780 (diff)
downloaddino-8e7dedcaa62a49373c22dfc54bf1bb8b261bcb61.tar.gz
dino-8e7dedcaa62a49373c22dfc54bf1bb8b261bcb61.zip
Allow blocking entire domain from conversation details
- the block domain option is in a drop down of the block button - when blocking the domain, the "Blocked domain" button appears and block button disappears and vice versa.
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/conversation_details.vala40
-rw-r--r--main/src/view_model/conversation_details.vala13
-rw-r--r--main/src/windows/conversation_details.vala19
3 files changed, 58 insertions, 14 deletions
diff --git a/main/src/ui/conversation_details.vala b/main/src/ui/conversation_details.vala
index 1c82f105..90aa9244 100644
--- a/main/src/ui/conversation_details.vala
+++ b/main/src/ui/conversation_details.vala
@@ -10,6 +10,7 @@ namespace Dino.Ui.ConversationDetails {
model.conversation = conversation;
model.display_name = stream_interactor.get_module(ContactModels.IDENTITY).get_display_name_model(conversation);
model.blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart);
+ model.domain_blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart.domain_jid);
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
stream_interactor.get_module(MucManager.IDENTITY).get_config_form.begin(conversation.account, conversation.counterpart, (_, res) => {
@@ -58,6 +59,7 @@ namespace Dino.Ui.ConversationDetails {
return true;
});
model.bind_property("blocked", view_model, "blocked", BindingFlags.SYNC_CREATE);
+ model.bind_property("domain_blocked", view_model, "domain_blocked", BindingFlags.SYNC_CREATE);
model.bind_property("data-form", view_model, "room-configuration-rows", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
var data_form = (DataForms.DataForm) from;
if (data_form == null) return true;
@@ -77,13 +79,37 @@ namespace Dino.Ui.ConversationDetails {
view_model.pin_changed.connect(() => {
model.conversation.pinned = model.conversation.pinned == 1 ? 0 : 1;
});
- view_model.block_changed.connect(() => {
- if (view_model.blocked) {
- stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart);
- } else {
- stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart);
+ view_model.block_changed.connect((action) => {
+ switch (action) {
+ case USER:
+ stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart);
+ view_model.blocked = true;
+ break;
+ case DOMAIN:
+ stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart.domain_jid);
+ view_model.blocked = true;
+ view_model.domain_blocked = true;
+ break;
+ case UNBLOCK:
+ stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart);
+ stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart.domain_jid);
+ view_model.blocked = false;
+ view_model.domain_blocked = false;
+ break;
+ case TOGGLE:
+ if (view_model.blocked) {
+ view_model.block_changed(UNBLOCK);
+ }
+ else {
+ view_model.block_changed(USER);
+ }
+ if (view_model.domain_blocked) {
+ view_model.block_changed(UNBLOCK);
+ }
+ break;
+ default:
+ break;
}
- view_model.blocked = !view_model.blocked;
});
view_model.notification_changed.connect((setting) => {
switch (setting) {
@@ -189,4 +215,4 @@ namespace Dino.Ui.ConversationDetails {
break;
}
}
-} \ No newline at end of file
+}
diff --git a/main/src/view_model/conversation_details.vala b/main/src/view_model/conversation_details.vala
index 15bf7535..9a34be78 100644
--- a/main/src/view_model/conversation_details.vala
+++ b/main/src/view_model/conversation_details.vala
@@ -6,10 +6,17 @@ using Gtk;
public class Dino.Ui.ViewModel.ConversationDetails : Object {
public signal void pin_changed();
- public signal void block_changed();
+ public signal void block_changed(BlockActions action);
public signal void notification_flipped();
public signal void notification_changed(NotificationSetting setting);
+ public enum BlockActions {
+ USER,
+ DOMAIN,
+ UNBLOCK,
+ TOGGLE
+ }
+
public enum NotificationOptions {
ON_OFF,
ON_HIGHLIGHT_OFF
@@ -32,6 +39,7 @@ public class Dino.Ui.ViewModel.ConversationDetails : Object {
public bool show_blocked { get; set; }
public bool blocked { get; set; }
+ public bool domain_blocked { get; set; }
public GLib.ListStore preferences_rows = new GLib.ListStore(typeof(PreferencesRow.Any));
public GLib.ListStore about_rows = new GLib.ListStore(typeof(PreferencesRow.Any));
@@ -46,4 +54,5 @@ public class Dino.Ui.Model.ConversationDetails : Object {
public DataForms.DataForm? data_form { get; set; }
public string? data_form_bak;
public bool blocked { get; set; }
-} \ No newline at end of file
+ public bool domain_blocked { get; set; }
+}
diff --git a/main/src/windows/conversation_details.vala b/main/src/windows/conversation_details.vala
index 1dac02c7..b2b33fa3 100644
--- a/main/src/windows/conversation_details.vala
+++ b/main/src/windows/conversation_details.vala
@@ -11,7 +11,7 @@ namespace Dino.Ui.ConversationDetails {
[GtkChild] public unowned Box about_box;
[GtkChild] public unowned Button pin_button;
[GtkChild] public unowned Adw.ButtonContent pin_button_content;
- [GtkChild] public unowned Button block_button;
+ [GtkChild] public unowned Adw.SplitButton block_button;
[GtkChild] public unowned Adw.ButtonContent block_button_content;
[GtkChild] public unowned Button notification_button_toggle;
[GtkChild] public unowned Adw.ButtonContent notification_button_toggle_content;
@@ -27,16 +27,20 @@ namespace Dino.Ui.ConversationDetails {
install_action("notification.off", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.OFF); } );
install_action("notification.highlight", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.HIGHLIGHT); } );
install_action("notification.default", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.DEFAULT); } );
+ install_action("do.block", null, (widget, action_name) => { ((Dialog) widget).model.block_changed(ViewModel.ConversationDetails.BlockActions.USER); } );
+ install_action("do.block_domain", null, (widget, action_name) => { ((Dialog) widget).model.block_changed(ViewModel.ConversationDetails.BlockActions.DOMAIN); } );
+ install_action("do.unblock", null, (widget, action_name) => { ((Dialog) widget).model.block_changed(ViewModel.ConversationDetails.BlockActions.UNBLOCK); } );
}
construct {
pin_button.clicked.connect(() => { model.pin_changed(); });
- block_button.clicked.connect(() => { model.block_changed(); });
+ block_button.clicked.connect(() => { model.block_changed(ViewModel.ConversationDetails.BlockActions.TOGGLE); });
notification_button_toggle.clicked.connect(() => { model.notification_flipped(); });
notification_button_split.clicked.connect(() => { model.notification_flipped(); });
model.notify["pinned"].connect(update_pinned_button);
model.notify["blocked"].connect(update_blocked_button);
+ model.notify["domain-blocked"].connect(update_blocked_button);
model.notify["notification"].connect(update_notification_button);
model.notify["notification"].connect(update_notification_button_state);
model.notify["notification-options"].connect(update_notification_button_visibility);
@@ -64,13 +68,18 @@ namespace Dino.Ui.ConversationDetails {
}
private void update_blocked_button() {
- block_button_content.icon_name = "dino-block-symbolic";
- block_button_content.label = model.blocked ? _("Blocked") : _("Block");
if (model.blocked) {
+ block_button_content.label = _("Blocked");
block_button.add_css_class("error");
} else {
+ block_button_content.label = _("Block");
block_button.remove_css_class("error");
}
+
+ if (model.domain_blocked) {
+ block_button_content.label = _("Domain blocked");
+ block_button.add_css_class("error");
+ }
}
private void update_notification_button() {
@@ -229,4 +238,4 @@ namespace Dino.Ui.ConversationDetails {
return preference_group;
}
}
-} \ No newline at end of file
+}