@@ -14,7 +14,7 @@ struct ChannelData{
16// TODO: make search controller availiable
16// TODO: make search controller availiable
17−class ChannelListController: UITableViewController, DataDelegate {
17+class ChannelListController: UITableViewController {
19 // MARK: - Output -
19 // MARK: - Output -
20 var onChannelSelected: ((Model.Channels) -> Void)?
20 var onChannelSelected: ((Model.Channels) -> Void)?
@@ -22,7 +22,6 @@ class ChannelListController: UITableViewController, DataDelegate {
22 // MARK: - filter search controller
22 // MARK: - filter search controller
23 var filteredDataSource = [Model.Channels]()
23 var filteredDataSource = [Model.Channels]()
25− var myProtocol: DataDelegate?
26 var displayingChannel: Model.Channels?
25 var displayingChannel: Model.Channels?
28 var toReload: Bool = false {
27 var toReload: Bool = false {
@@ -97,7 +96,6 @@ class ChannelListController: UITableViewController, DataDelegate {
97 // editing mode is on automatically
96 // editing mode is on automatically
98 let vc = storyboard?.instantiateViewController(withIdentifier: channelControllerId) as! ChannelController
97 let vc = storyboard?.instantiateViewController(withIdentifier: channelControllerId) as! ChannelController
99 vc.index = 1
98 vc.index = 1
100− vc.myProtocol = self
101 vc.channel = Model.Channels(people: [], name: "Untitled", tags: [])
99 vc.channel = Model.Channels(people: [], name: "Untitled", tags: [])
102 navigationController?.pushViewController(vc, animated: true)
100 navigationController?.pushViewController(vc, animated: true)
@@ -147,7 +145,6 @@ class ChannelListController: UITableViewController, DataDelegate {
147 let editButton = UITableViewRowAction(style: .normal, title: "Edit") { [weak self] (action, indexPath) in
145 let editButton = UITableViewRowAction(style: .normal, title: "Edit") { [weak self] (action, indexPath) in
148 let vc = self?.storyboard?.instantiateViewController(withIdentifier: channelControllerId) as! ChannelController
146 let vc = self?.storyboard?.instantiateViewController(withIdentifier: channelControllerId) as! ChannelController
149 vc.index = indexPath.row
147 vc.index = indexPath.row
150− vc.myProtocol = self!
151 vc.channel = self?.dataSource[indexPath.row]
148 vc.channel = self?.dataSource[indexPath.row]
152 self?.navigationController?.pushViewController(vc, animated: true)
149 self?.navigationController?.pushViewController(vc, animated: true)
@@ -159,11 +156,7 @@ class ChannelListController: UITableViewController, DataDelegate {
159 Model.channelsDelete(by: self!.dataSource[indexPath.row].id!, completion: {
156 Model.channelsDelete(by: self!.dataSource[indexPath.row].id!, completion: {
160 print("хз что тут делать при успехе")
157 print("хз что тут делать при успехе")
163− if (self!.dataSource[indexPath.row].id == self!.displayingChannel?.id ?? -1)
165− self?.myProtocol?.passData(for: 0, channel: self!.dataSource[0])
167 self?.tableView.beginUpdates()
160 self?.tableView.beginUpdates()
168 self?.dataSource.remove(at: indexPath.row)
161 self?.dataSource.remove(at: indexPath.row)
169 self?.tableView.deleteRows(at: [indexPath], with: .none)
162 self?.tableView.deleteRows(at: [indexPath], with: .none)
@@ -175,17 +168,12 @@ class ChannelListController: UITableViewController, DataDelegate {
175 return [editButton, deleteButton]
168 return [editButton, deleteButton]
178− // TODO: remove popping
179 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
171 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
181 if isFiltering {
173 if isFiltering {
182− //onChannelSelected?(filteredDataSource[indexPath.row])
174+ onChannelSelected?(filteredDataSource[indexPath.row])
183− myProtocol?.passData(for: 0, channel: filteredDataSource[indexPath.row])
184− navigationController?.popViewController(animated: true)
186− myProtocol?.passData(for: 0, channel: dataSource[indexPath.row])
187− navigationController?.popViewController(animated: true)
188− //onChannelSelected?(ChannelListController.dataSource[indexPath.row])
176+ onChannelSelected?(dataSource[indexPath.row])