π
Jan 9th 2019
π 21 days until launch
π₯ 9 day streak
π€ 0 usd
π 0 customers
βοΈ 7.55 hours spent
π» 18 files changed, 987 insertions(+), 171 deletions(-)
π Today's goals: Edit/delete existing passwords
11:35 PM
Definitely the most focused day since I only had 30 minutes before midnight, just going to get the delete working from the menu, definitely have to pick up the pace tomorrow though.
11:49 PM
I've done it, I've cracked the code. Luckily functional programming translates into most other languages pretty well, even the statically typed ones (I'm coming from clojure). What I needed to do was map the delete menu item to a function in AppDelegate.swift then do the old first responder trick and finally copy and paste that function definition to PasswordListViewController.swift.
From there it was just figuring out how to get multiple rows out of the array of Row objects and viola, sqlite.swift could take over with a .filter([].contains(id)). Here's how it looks in code
@IBAction func deleteLogin(_ sender: NSMenuItem) {
do {
let indices = tableView.selectedRowIndexes
let ids = indices.compactMap { (logins?.count ?? -1 > $0) ? logins?[$0][login.id] : nil}
let lg = login.table.filter(ids.contains(login.id))
if try db.run(lg.delete()) > 0 {
logins = Array(try! db.prepare(login.table))
tableView.reloadData()
} else {
print("login not found")
}
} catch {
print("delete failed: \(error)")
}
}
βοΈ ~8 hours spent. Tomorrow will be a much more productive day. I'm sure of it
Top comments (0)