|
@@ -655,7 +655,7 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- if self.groups[c].parent == id {
|
|
|
+ if c < self.groups.count && self.groups[c].parent == id {
|
|
|
sects = sects + 1
|
|
|
sect = c
|
|
|
id = self.groups[c].id
|
|
@@ -698,17 +698,31 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
return
|
|
|
}
|
|
|
if group.childs.count == 0 {
|
|
|
- let groupId = group.chatId.isEmpty ? group.id : group.chatId
|
|
|
- if let chooser = isChooser {
|
|
|
- chooser("4", groupId)
|
|
|
- dismiss(animated: true, completion: nil)
|
|
|
- return
|
|
|
- }
|
|
|
- self.groupMap.removeAll()
|
|
|
- let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
|
|
|
- editorGroupVC.hidesBottomBarWhenPushed = true
|
|
|
- editorGroupVC.unique_l_pin = groupId
|
|
|
- navigationController?.show(editorGroupVC, sender: nil)
|
|
|
+ Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
+ let idMe = UserDefaults.standard.string(forKey: "me") as String?
|
|
|
+ if let cursorMember = Database.shared.getRecords(fmdb: fmdb, query: "select f_pin from GROUPZ_MEMBER where group_id = '\(group.id)' and f_pin = '\(idMe!)'"), cursorMember.next() {
|
|
|
+ let groupId = group.chatId.isEmpty ? group.id : group.chatId
|
|
|
+ if let chooser = isChooser {
|
|
|
+ chooser("4", groupId)
|
|
|
+ dismiss(animated: true, completion: nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ self.groupMap.removeAll()
|
|
|
+ let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorGroupVC") as! EditorGroup
|
|
|
+ editorGroupVC.hidesBottomBarWhenPushed = true
|
|
|
+ editorGroupVC.unique_l_pin = groupId
|
|
|
+ navigationController?.show(editorGroupVC, sender: nil)
|
|
|
+ cursorMember.close()
|
|
|
+ } else {
|
|
|
+ var viewController = UIApplication.shared.windows.first!.rootViewController
|
|
|
+ if !(viewController is ViewController) {
|
|
|
+ viewController = self.parent
|
|
|
+ }
|
|
|
+ if let viewController = viewController as? ViewController {
|
|
|
+ viewController.view.makeToast("You are not a member of this group".localized(), duration: 0.5)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
} else {
|
|
|
if indexPath.row == 0 {
|
|
|
tableView.reloadData()
|