Skip to content

Commit

Permalink
Update group view controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Rush committed Nov 15, 2016
1 parent 12c45ae commit 7494b17
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
26 changes: 13 additions & 13 deletions MiniKeePass/Group View/GroupViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ class GroupViewController: UITableViewController {
private var groups: [KdbGroup]!
private var entries: [KdbEntry]!

var parentGroup: KdbGroup!
var parentGroup: KdbGroup! {
didSet {
updateViewModel()
}
}

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -72,13 +76,6 @@ class GroupViewController: UITableViewController {
toolbarItems = standardToolbarItems
}

override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)

// FIXME
updateViewModel()
}

override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)

Expand Down Expand Up @@ -444,6 +441,14 @@ class GroupViewController: UITableViewController {

// Update the table
self.tableView.deleteRowsAtIndexPaths(indexPaths, withRowAnimation: .Automatic)
let indexSet = NSMutableIndexSet()
if (self.groups.isEmpty) {
indexSet.addIndex(Section.Groups.rawValue)
}
if (self.entries.isEmpty) {
indexSet.addIndex(Section.Entries.rawValue)
}
self.tableView.reloadSections(indexSet, withRowAnimation: .Automatic)

self.setEditing(false, animated: true)
}
Expand All @@ -460,11 +465,6 @@ class GroupViewController: UITableViewController {

let viewController = navigationController.topViewController as! RenameItemViewController
viewController.donePressed = { (renameItemViewController: RenameItemViewController) -> Void in
// Save the database
let appDelegate = MiniKeePassAppDelegate.getDelegate()
let databaseDocument = appDelegate.databaseDocument
databaseDocument.save()

// Update the table
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)

Expand Down
1 change: 0 additions & 1 deletion MiniKeePass/MiniKeePassAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#import "MiniKeePassAppDelegate.h"
#import "GroupViewControllerOld.h"
#import "EntryViewController.h"
#import "AppSettings.h"
#import "DatabaseManager.h"
Expand Down

0 comments on commit 7494b17

Please sign in to comment.