[+] Implement delete family

This commit is contained in:
Hykilpikonna
2021-01-24 21:12:24 -05:00
parent 6aed3cf6b4
commit 2bda42b36d
2 changed files with 23 additions and 7 deletions
+12 -5
View File
@@ -262,16 +262,23 @@ class FamilyVC: UIViewController
}
/**
Called when the user clicks the leave family button
Called when the user clicks the leave or delete family button
*/
@IBAction func btnLeave(_ sender: Any)
@IBAction func btnLeave(_ sender: UIButton)
{
let i = sender.tag
let action = ["Leave", "Delete"][i]
let title = ["Leaving...", "Deleting..."][i]
let msg = ["You left the family.", "You deleted the family."][i]
enterPin()
{
self.sendReq(APIs.familyChangePin, title: "Leaving...", params: ["pin": $0]) { it in
self.sendReq(APIs.familyAction, title: title, params: ["pin": $0, "action": action]) { it in
localStorage.removeObject(forKey: "family")
self.msg("Leave Success!", "You left the family.")
// Leave or delete, clear local storage's family section
if i == 0 || i == 1 { localStorage.removeObject(forKey: "family") }
self.msg("\(action) Success!", msg)
}
}
}