From fa78573b052693b29350bdd0f7eaf74dc6571e4a Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 22 Mar 2017 17:15:06 +0100 Subject: Move some database interaction into entities fixes #2 --- main/src/ui/manage_accounts/add_account_dialog.vala | 9 ++++----- main/src/ui/manage_accounts/dialog.vala | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'main') diff --git a/main/src/ui/manage_accounts/add_account_dialog.vala b/main/src/ui/manage_accounts/add_account_dialog.vala index f6ad40a2..8501f476 100644 --- a/main/src/ui/manage_accounts/add_account_dialog.vala +++ b/main/src/ui/manage_accounts/add_account_dialog.vala @@ -49,11 +49,10 @@ public class AddAccountDialog : Gtk.Dialog { } private void on_ok_button_clicked() { - Account account = new Account.from_bare_jid(jid_entry.get_text()); - account.resourcepart = "dino"; - account.alias = alias_entry.get_text(); - account.enabled = false; - account.password = password_entry.get_text(); + Jid jid = new Jid(jid_entry.get_text()); + string password = password_entry.get_text(); + string alias = alias_entry.get_text(); + Account account = new Account(jid, null, password, alias); added(account); close(); } diff --git a/main/src/ui/manage_accounts/dialog.vala b/main/src/ui/manage_accounts/dialog.vala index db40761d..c0689474 100644 --- a/main/src/ui/manage_accounts/dialog.vala +++ b/main/src/ui/manage_accounts/dialog.vala @@ -98,7 +98,7 @@ public class Dialog : Gtk.Window { AddAccountDialog add_account_dialog = new AddAccountDialog(stream_interactor); add_account_dialog.set_transient_for(this); add_account_dialog.added.connect((account) => { - db.add_account(account); + account.persist(db); AccountRow account_item = add_account(account); account_list.select_row(account_item); account_list.queue_draw(); @@ -112,7 +112,7 @@ public class Dialog : Gtk.Window { account_list.remove(account_item); account_list.queue_draw(); if (account_item.account.enabled) account_disabled(account_item.account); - db.remove_account(account_item.account); + account_item.account.remove(); if (account_list.get_row_at_index(0) != null) { account_list.select_row(account_list.get_row_at_index(0)); } else { -- cgit v1.2.3-70-g09d2