aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/add_conversation/roster_list.vala
diff options
context:
space:
mode:
authorMiquel Lionel <lionel@les-miquelots.net>2023-09-17 13:14:43 +0200
committerMiquel Lionel <lionel@les-miquelots.net>2024-08-25 15:31:09 +0200
commit62cdea3a5e701c04f3a7fd9d6b5f48e28fef1f72 (patch)
treed6876d251ae148dbf80080823f51c142c0f9f8ad /main/src/ui/add_conversation/roster_list.vala
parent8be4f02723fc131d9275c1b70831f53ff4630a1a (diff)
downloaddino-62cdea3a5e701c04f3a7fd9d6b5f48e28fef1f72.tar.gz
dino-62cdea3a5e701c04f3a7fd9d6b5f48e28fef1f72.zip
Simplify talking to yourself (notes) on the UI
- clicking on the menu will multiple accounts will bring up a modified "start chat" windows
Diffstat (limited to 'main/src/ui/add_conversation/roster_list.vala')
-rw-r--r--main/src/ui/add_conversation/roster_list.vala35
1 files changed, 21 insertions, 14 deletions
diff --git a/main/src/ui/add_conversation/roster_list.vala b/main/src/ui/add_conversation/roster_list.vala
index bb338ce5..ebbe55e7 100644
--- a/main/src/ui/add_conversation/roster_list.vala
+++ b/main/src/ui/add_conversation/roster_list.vala
@@ -16,37 +16,37 @@ protected class RosterList {
private ListBox list_box = new ListBox();
private HashMap<Account, HashMap<Jid, ListBoxRow>> rows = new HashMap<Account, HashMap<Jid, ListBoxRow>>(Account.hash_func, Account.equals_func);
- public RosterList(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
+ public RosterList(StreamInteractor stream_interactor, Gee.List<Account> accounts, bool notes_mode = false) {
this.stream_interactor = stream_interactor;
this.accounts = accounts;
- handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).removed_roster_item.connect( (account, jid, roster_item) => {
+ handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).removed_roster_item.connect( (account, jid) => {
if (accounts.contains(account)) {
- on_removed_roster_item(account, jid, roster_item);
+ remove_row(account, jid);
}
});
- handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect( (account, jid, roster_item) => {
+ handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect( (account, jid) => {
if (accounts.contains(account)) {
- on_updated_roster_item(account, jid, roster_item);
+ update_row(account, jid);
}
});
list_box.destroy.connect(() => {
foreach (ulong handler_id in handler_ids) stream_interactor.get_module(RosterManager.IDENTITY).disconnect(handler_id);
});
- foreach (Account a in accounts) fetch_roster_items(a);
+ foreach (Account a in accounts) fetch_roster_items(a, notes_mode);
}
- private void on_removed_roster_item(Account account, Jid jid, Roster.Item roster_item) {
+ private void remove_row(Account account, Jid jid) {
if (rows.has_key(account) && rows[account].has_key(jid)) {
list_box.remove(rows[account][jid]);
rows[account].unset(jid);
}
}
- private void on_updated_roster_item(Account account, Jid jid, Roster.Item roster_item) {
- on_removed_roster_item(account, jid, roster_item);
- ListRow row = new ListRow.from_jid(stream_interactor, roster_item.jid, account, accounts.size > 1);
+ private void update_row(Account account, Jid jid) {
+ remove_row(account, jid);
+ ListRow row = new ListRow.from_jid(stream_interactor, jid, account, accounts.size > 1);
ListBoxRow list_box_row = new ListBoxRow() { child=row };
rows[account][jid] = list_box_row;
list_box.append(list_box_row);
@@ -54,10 +54,17 @@ protected class RosterList {
list_box.invalidate_filter();
}
- private void fetch_roster_items(Account account) {
- rows[account] = new HashMap<Jid, ListBoxRow>(Jid.hash_func, Jid.equals_func);
- foreach (Roster.Item roster_item in stream_interactor.get_module(RosterManager.IDENTITY).get_roster(account)) {
- on_updated_roster_item(account, roster_item.jid, roster_item);
+ private void fetch_roster_items(Account account, bool notes_mode = false) {
+ if (!notes_mode){
+ rows[account] = new HashMap<Jid, ListBoxRow>(Jid.hash_func, Jid.equals_func);
+ foreach (Roster.Item roster_item in stream_interactor.get_module(RosterManager.IDENTITY).get_roster(account)) {
+ update_row(account, roster_item.jid);
+ }
+ }
+ else {
+ ListRow own_account_row = new ListRow.from_jid(stream_interactor, account.bare_jid, account, accounts.size > 1);
+ ListBoxRow own_account_lbrow = new ListBoxRow() { child=own_account_row };
+ list_box.append(own_account_lbrow);
}
}