Skip to content

Instantly share code, notes, and snippets.

@zontan
Last active July 6, 2020 23:18
Show Gist options
  • Save zontan/eafb048621b145e48f6704765e4e9961 to your computer and use it in GitHub Desktop.
Save zontan/eafb048621b145e48f6704765e4e9961 to your computer and use it in GitHub Desktop.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let uid = resultsArray[indexPath.row]
userRef.child(uid).child("locked").observeSingleEvent(of: .value) { (snapshot) in
if let lockState = snapshot.value as? String, lockState == "true" {
DispatchQueue.main.async {
self.tableView.deselectRow(at: indexPath, animated: true)
let alert = UIAlertController(title: "Locked", message: "That user's room is currently locked.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
} else {
self.delegate?.didJoinFriend(uid: uid)
self.dismiss(animated: true, completion: nil)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment