NCCreateFormUploadConflict.swift 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. //
  2. // NCCreateFormUploadConflict.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 29/03/2020.
  6. // Copyright © 2020 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import UIKit
  24. import SwiftUI
  25. import NextcloudKit
  26. import Photos
  27. protocol NCCreateFormUploadConflictDelegate: AnyObject {
  28. func dismissCreateFormUploadConflict(metadatas: [tableMetadata]?)
  29. }
  30. class NCCreateFormUploadConflict: UIViewController {
  31. @IBOutlet weak var labelTitle: UILabel!
  32. @IBOutlet weak var labelSubTitle: UILabel!
  33. @IBOutlet weak var viewSwitch: UIView!
  34. @IBOutlet weak var switchNewFiles: UISwitch!
  35. @IBOutlet weak var switchAlreadyExistingFiles: UISwitch!
  36. @IBOutlet weak var labelNewFiles: UILabel!
  37. @IBOutlet weak var labelAlreadyExistingFiles: UILabel!
  38. @IBOutlet weak var tableView: UITableView!
  39. @IBOutlet weak var viewButton: UIView!
  40. @IBOutlet weak var buttonCancel: UIButton!
  41. @IBOutlet weak var buttonContinue: UIButton!
  42. var account: String
  43. var metadatasNOConflict: [tableMetadata]
  44. var metadatasUploadInConflict: [tableMetadata]
  45. var serverUrl: String?
  46. var delegate: NCCreateFormUploadConflictDelegate?
  47. var alwaysNewFileNameNumber: Bool = false
  48. var textLabelDetailNewFile: String?
  49. var metadatasConflictNewFiles: [String] = []
  50. var metadatasConflictAlreadyExistingFiles: [String] = []
  51. let fileNamesPath = ThreadSafeDictionary<String, String>()
  52. var blurView: UIVisualEffectView!
  53. let utility = NCUtility()
  54. let utilityFileSystem = NCUtilityFileSystem()
  55. // MARK: - View Life Cycle
  56. required init?(coder aDecoder: NSCoder) {
  57. self.account = ""
  58. self.metadatasNOConflict = []
  59. self.metadatasUploadInConflict = []
  60. super.init(coder: aDecoder)
  61. }
  62. override func viewDidLoad() {
  63. super.viewDidLoad()
  64. tableView.dataSource = self
  65. tableView.delegate = self
  66. tableView.allowsSelection = false
  67. tableView.tableFooterView = UIView()
  68. view.backgroundColor = .systemGroupedBackground
  69. tableView.backgroundColor = .systemGroupedBackground
  70. viewSwitch.backgroundColor = .systemGroupedBackground
  71. viewButton.backgroundColor = .systemGroupedBackground
  72. tableView.register(UINib(nibName: "NCCreateFormUploadConflictCell", bundle: nil), forCellReuseIdentifier: "Cell")
  73. if metadatasUploadInConflict.count == 1 {
  74. labelTitle.text = String(metadatasUploadInConflict.count) + " " + NSLocalizedString("_file_conflict_num_", comment: "")
  75. labelSubTitle.text = NSLocalizedString("_file_conflict_desc_", comment: "")
  76. labelNewFiles.text = NSLocalizedString("_file_conflict_new_", comment: "")
  77. labelAlreadyExistingFiles.text = NSLocalizedString("_file_conflict_exists_", comment: "")
  78. } else {
  79. labelTitle.text = String(metadatasUploadInConflict.count) + " " + NSLocalizedString("_file_conflicts_num_", comment: "")
  80. labelSubTitle.text = NSLocalizedString("_file_conflict_desc_", comment: "")
  81. labelNewFiles.text = NSLocalizedString("_file_conflict_new_", comment: "")
  82. labelAlreadyExistingFiles.text = NSLocalizedString("_file_conflict_exists_", comment: "")
  83. }
  84. switchNewFiles.onTintColor = NCBrandColor.shared.getElement(account: account)
  85. switchNewFiles.isOn = false
  86. switchAlreadyExistingFiles.onTintColor = NCBrandColor.shared.getElement(account: account)
  87. switchAlreadyExistingFiles.isOn = false
  88. buttonCancel.layer.cornerRadius = 20
  89. buttonCancel.layer.masksToBounds = true
  90. buttonCancel.layer.borderWidth = 0.5
  91. buttonCancel.layer.borderColor = UIColor.darkGray.cgColor
  92. buttonCancel.backgroundColor = .systemGray5
  93. buttonCancel.setTitle(NSLocalizedString("_cancel_", comment: ""), for: .normal)
  94. buttonCancel.setTitleColor(NCBrandColor.shared.textColor, for: .normal)
  95. buttonContinue.layer.cornerRadius = 20
  96. buttonContinue.layer.masksToBounds = true
  97. buttonContinue.backgroundColor = NCBrandColor.shared.getElement(account: account)
  98. buttonContinue.setTitle(NSLocalizedString("_continue_", comment: ""), for: .normal)
  99. buttonContinue.isEnabled = false
  100. buttonContinue.setTitleColor(.white, for: .normal)
  101. let blurEffect = UIBlurEffect(style: .light)
  102. blurView = UIVisualEffectView(effect: blurEffect)
  103. blurView.frame = view.bounds
  104. blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  105. view.addSubview(blurView)
  106. DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
  107. self.conflictDialog(fileCount: self.metadatasUploadInConflict.count)
  108. }
  109. }
  110. // MARK: - ConflictDialog
  111. func conflictDialog(fileCount: Int) {
  112. var tile = ""
  113. var titleReplace = ""
  114. var titleKeep = ""
  115. if fileCount == 1 {
  116. tile = NSLocalizedString("_single_file_conflict_title_", comment: "")
  117. titleReplace = NSLocalizedString("_replace_action_title_", comment: "")
  118. titleKeep = NSLocalizedString("_keep_both_action_title_", comment: "")
  119. } else {
  120. tile = String.localizedStringWithFormat(NSLocalizedString("_multi_file_conflict_title_", comment: ""), String(fileCount))
  121. titleReplace = NSLocalizedString("_replace_all_action_title_", comment: "")
  122. titleKeep = NSLocalizedString("_keep_both_for_all_action_title_", comment: "")
  123. }
  124. let conflictAlert = UIAlertController(title: tile, message: "", preferredStyle: .alert)
  125. // KEEP BOTH
  126. conflictAlert.addAction(UIAlertAction(title: titleKeep, style: .default, handler: { action in
  127. for metadata in self.metadatasUploadInConflict {
  128. self.metadatasConflictNewFiles.append(metadata.ocId)
  129. self.metadatasConflictAlreadyExistingFiles.append(metadata.ocId)
  130. }
  131. self.buttonContinueTouch(action)
  132. }))
  133. // REPLACE
  134. conflictAlert.addAction(UIAlertAction(title: titleReplace, style: .default, handler: { action in
  135. for metadata in self.metadatasUploadInConflict {
  136. self.metadatasNOConflict.append(metadata)
  137. }
  138. self.buttonContinueTouch(action)
  139. }))
  140. // MORE
  141. conflictAlert.addAction(UIAlertAction(title: NSLocalizedString("_more_action_title_", comment: ""), style: .default, handler: { _ in
  142. self.blurView.removeFromSuperview()
  143. }))
  144. // CANCEL
  145. conflictAlert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_keep_existing_action_title_", comment: ""), style: .cancel, handler: { _ in
  146. self.dismiss(animated: true) {
  147. self.delegate?.dismissCreateFormUploadConflict(metadatas: nil)
  148. }
  149. }))
  150. self.present(conflictAlert, animated: true, completion: nil)
  151. }
  152. // MARK: - Action
  153. @IBAction func valueChangedSwitchNewFiles(_ sender: Any) {
  154. metadatasConflictNewFiles.removeAll()
  155. if switchNewFiles.isOn {
  156. for metadata in metadatasUploadInConflict {
  157. metadatasConflictNewFiles.append(metadata.ocId)
  158. }
  159. }
  160. verifySwith()
  161. }
  162. @IBAction func valueChangedSwitchAlreadyExistingFiles(_ sender: Any) {
  163. metadatasConflictAlreadyExistingFiles.removeAll()
  164. if switchAlreadyExistingFiles.isOn {
  165. for metadata in metadatasUploadInConflict {
  166. metadatasConflictAlreadyExistingFiles.append(metadata.ocId)
  167. }
  168. }
  169. verifySwith()
  170. }
  171. func verifySwith() {
  172. if alwaysNewFileNameNumber && switchNewFiles.isOn {
  173. metadatasConflictNewFiles.removeAll()
  174. metadatasConflictAlreadyExistingFiles.removeAll()
  175. for metadata in metadatasUploadInConflict {
  176. metadatasConflictNewFiles.append(metadata.ocId)
  177. }
  178. for metadata in metadatasUploadInConflict {
  179. metadatasConflictAlreadyExistingFiles.append(metadata.ocId)
  180. }
  181. switchAlreadyExistingFiles.isOn = true
  182. let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_file_not_rewite_doc_")
  183. NCContentPresenter().showInfo(error: error)
  184. }
  185. tableView.reloadData()
  186. canContinue()
  187. }
  188. @IBAction func buttonCancelTouch(_ sender: Any) {
  189. dismiss(animated: true) {
  190. self.delegate?.dismissCreateFormUploadConflict(metadatas: nil)
  191. }
  192. }
  193. @IBAction func buttonContinueTouch(_ sender: Any) {
  194. for metadata in metadatasUploadInConflict {
  195. // keep both
  196. if metadatasConflictNewFiles.contains(metadata.ocId) && metadatasConflictAlreadyExistingFiles.contains(metadata.ocId) {
  197. var fileName = metadata.fileNameView
  198. let fileNameExtension = (fileName as NSString).pathExtension.lowercased()
  199. let fileNameNoExtension = (fileName as NSString).deletingPathExtension
  200. if fileNameExtension == "heic" && NCKeychain().formatCompatibility {
  201. fileName = fileNameNoExtension + ".jpg"
  202. }
  203. let oldPath = utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)
  204. let newFileName = utilityFileSystem.createFileName(fileName, serverUrl: metadata.serverUrl, account: metadata.account)
  205. metadata.ocId = UUID().uuidString
  206. metadata.fileName = newFileName
  207. metadata.fileNameView = newFileName
  208. // This is not an asset - [file]
  209. if metadata.assetLocalIdentifier.isEmpty || metadata.isExtractFile {
  210. let newPath = utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: newFileName)
  211. utilityFileSystem.moveFile(atPath: oldPath, toPath: newPath)
  212. }
  213. metadatasNOConflict.append(metadata)
  214. // overwrite
  215. } else if metadatasConflictNewFiles.contains(metadata.ocId) {
  216. metadatasNOConflict.append(metadata)
  217. } else {
  218. // used UIAlert (replace all)
  219. }
  220. }
  221. dismiss(animated: true) {
  222. self.delegate?.dismissCreateFormUploadConflict(metadatas: self.metadatasNOConflict)
  223. }
  224. }
  225. }
  226. // MARK: - UITableViewDelegate
  227. extension NCCreateFormUploadConflict: UITableViewDelegate {
  228. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  229. if metadatasUploadInConflict.count == 1 {
  230. return 250
  231. } else {
  232. return 280
  233. }
  234. }
  235. }
  236. // MARK: - UITableViewDataSource
  237. extension NCCreateFormUploadConflict: UITableViewDataSource {
  238. func numberOfSections(in tableView: UITableView) -> Int {
  239. return 1
  240. }
  241. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  242. return metadatasUploadInConflict.count
  243. }
  244. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  245. if let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? NCCreateFormUploadConflictCell {
  246. let metadataNewFile = tableMetadata.init(value: metadatasUploadInConflict[indexPath.row])
  247. cell.backgroundColor = tableView.backgroundColor
  248. cell.switchNewFile.onTintColor = NCBrandColor.shared.getElement(account: metadataNewFile.account)
  249. cell.switchAlreadyExistingFile.onTintColor = NCBrandColor.shared.getElement(account: metadataNewFile.account)
  250. cell.ocId = metadataNewFile.ocId
  251. cell.delegate = self
  252. cell.labelFileName.text = metadataNewFile.fileNameView
  253. cell.labelDetailAlreadyExistingFile.text = ""
  254. cell.labelDetailNewFile.text = ""
  255. // -----> Already Existing File
  256. guard let metadataAlreadyExists = NCManageDatabase.shared.getMetadataConflict(account: metadataNewFile.account, serverUrl: metadataNewFile.serverUrl, fileNameView: metadataNewFile.fileNameView) else { return UITableViewCell() }
  257. if utility.existsImage(ocId: metadataAlreadyExists.ocId, etag: metadataAlreadyExists.etag, ext: NCGlobal.shared.previewExt512) {
  258. cell.imageAlreadyExistingFile.image = UIImage(contentsOfFile: utilityFileSystem.getDirectoryProviderStorageImageOcId(metadataAlreadyExists.ocId, etag: metadataAlreadyExists.etag, ext: NCGlobal.shared.previewExt512))
  259. } else if FileManager().fileExists(atPath: utilityFileSystem.getDirectoryProviderStorageOcId(metadataAlreadyExists.ocId, fileNameView: metadataAlreadyExists.fileNameView)) && metadataAlreadyExists.contentType == "application/pdf" {
  260. let url = URL(fileURLWithPath: utilityFileSystem.getDirectoryProviderStorageOcId(metadataAlreadyExists.ocId, fileNameView: metadataAlreadyExists.fileNameView))
  261. if let image = utility.pdfThumbnail(url: url) {
  262. cell.imageAlreadyExistingFile.image = image
  263. } else {
  264. cell.imageAlreadyExistingFile.image = UIImage(named: metadataAlreadyExists.iconName)
  265. }
  266. } else {
  267. if metadataAlreadyExists.iconName.isEmpty {
  268. cell.imageAlreadyExistingFile.image = NCImageCache.shared.getImageFile()
  269. } else {
  270. cell.imageAlreadyExistingFile.image = UIImage(named: metadataAlreadyExists.iconName)
  271. }
  272. }
  273. cell.labelDetailAlreadyExistingFile.text = utility.dateDiff(metadataAlreadyExists.date as Date) + "\n" + utilityFileSystem.transformedSize(metadataAlreadyExists.size)
  274. if metadatasConflictAlreadyExistingFiles.contains(metadataNewFile.ocId) {
  275. cell.switchAlreadyExistingFile.isOn = true
  276. } else {
  277. cell.switchAlreadyExistingFile.isOn = false
  278. }
  279. // -----> New File
  280. if metadataNewFile.iconName.isEmpty {
  281. cell.imageNewFile.image = NCImageCache.shared.getImageFile()
  282. } else {
  283. cell.imageNewFile.image = UIImage(named: metadataNewFile.iconName)
  284. }
  285. let filePathNewFile = utilityFileSystem.getDirectoryProviderStorageOcId(metadataNewFile.ocId, fileNameView: metadataNewFile.fileNameView)
  286. if !metadataNewFile.assetLocalIdentifier.isEmpty {
  287. let result = PHAsset.fetchAssets(withLocalIdentifiers: [metadataNewFile.assetLocalIdentifier], options: nil)
  288. let date = result.firstObject!.modificationDate
  289. let mediaType = result.firstObject!.mediaType
  290. if let fileNamePath = self.fileNamesPath[metadataNewFile.fileNameView] {
  291. do {
  292. if mediaType == PHAssetMediaType.image {
  293. let data = try Data(contentsOf: URL(fileURLWithPath: fileNamePath))
  294. if let image = UIImage(data: data) {
  295. cell.imageNewFile.image = image
  296. }
  297. } else if mediaType == PHAssetMediaType.video {
  298. if let image = utility.imageFromVideo(url: URL(fileURLWithPath: fileNamePath), at: 0) {
  299. cell.imageNewFile.image = image
  300. }
  301. }
  302. let fileDictionary = try FileManager.default.attributesOfItem(atPath: fileNamePath)
  303. let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
  304. cell.labelDetailNewFile.text = utility.dateDiff(date) + "\n" + utilityFileSystem.transformedSize(fileSize)
  305. } catch { print("Error: \(error)") }
  306. } else {
  307. // PREVIEW
  308. let cameraRoll = NCCameraRoll()
  309. cameraRoll.extractImageVideoFromAssetLocalIdentifier(metadata: metadataNewFile, modifyMetadataForUpload: false) { _, fileNamePath, error in
  310. if !error {
  311. self.fileNamesPath[metadataNewFile.fileNameView] = fileNamePath!
  312. do {
  313. let fileDictionary = try FileManager.default.attributesOfItem(atPath: fileNamePath!)
  314. let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
  315. if mediaType == PHAssetMediaType.image {
  316. let data = try Data(contentsOf: URL(fileURLWithPath: fileNamePath!))
  317. if let image = UIImage(data: data) {
  318. DispatchQueue.main.async { cell.imageNewFile.image = image }
  319. }
  320. } else if mediaType == PHAssetMediaType.video {
  321. if let image = self.utility.imageFromVideo(url: URL(fileURLWithPath: fileNamePath!), at: 0) {
  322. DispatchQueue.main.async { cell.imageNewFile.image = image }
  323. }
  324. }
  325. DispatchQueue.main.async { cell.labelDetailNewFile.text = self.utility.dateDiff(date) + "\n" + self.utilityFileSystem.transformedSize(fileSize) }
  326. } catch { print("Error: \(error)") }
  327. }
  328. }
  329. }
  330. } else if FileManager().fileExists(atPath: filePathNewFile) {
  331. do {
  332. if metadataNewFile.classFile == NKCommon.TypeClassFile.image.rawValue {
  333. // preserver memory especially for very large files in Share extension
  334. if let image = UIImage.downsample(imageAt: URL(fileURLWithPath: filePathNewFile), to: cell.imageNewFile.frame.size) {
  335. cell.imageNewFile.image = image
  336. }
  337. }
  338. let fileDictionary = try FileManager.default.attributesOfItem(atPath: filePathNewFile)
  339. let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
  340. cell.labelDetailNewFile.text = utility.dateDiff(metadataNewFile.date as Date) + "\n" + utilityFileSystem.transformedSize(fileSize)
  341. } catch { print("Error: \(error)") }
  342. }
  343. if metadatasConflictNewFiles.contains(metadataNewFile.ocId) {
  344. cell.switchNewFile.isOn = true
  345. } else {
  346. cell.switchNewFile.isOn = false
  347. }
  348. // Hide switch if only one
  349. if metadatasUploadInConflict.count == 1 {
  350. cell.switchAlreadyExistingFile.isHidden = true
  351. cell.switchNewFile.isHidden = true
  352. }
  353. // text label new file
  354. if textLabelDetailNewFile != nil {
  355. cell.labelDetailNewFile.text = textLabelDetailNewFile! + "\n"
  356. }
  357. return cell
  358. }
  359. return UITableViewCell()
  360. }
  361. }
  362. // MARK: - NCCreateFormUploadConflictCellDelegate
  363. extension NCCreateFormUploadConflict: NCCreateFormUploadConflictCellDelegate {
  364. func valueChangedSwitchNewFile(with ocId: String, isOn: Bool) {
  365. if let index = metadatasConflictNewFiles.firstIndex(of: ocId) {
  366. metadatasConflictNewFiles.remove(at: index)
  367. }
  368. if isOn {
  369. metadatasConflictNewFiles.append(ocId)
  370. }
  371. if metadatasConflictNewFiles.count == metadatasUploadInConflict.count {
  372. switchNewFiles.isOn = true
  373. } else {
  374. switchNewFiles.isOn = false
  375. }
  376. canContinue()
  377. }
  378. func valueChangedSwitchAlreadyExistingFile(with ocId: String, isOn: Bool) {
  379. if let index = metadatasConflictAlreadyExistingFiles.firstIndex(of: ocId) {
  380. metadatasConflictAlreadyExistingFiles.remove(at: index)
  381. }
  382. if isOn {
  383. metadatasConflictAlreadyExistingFiles.append(ocId)
  384. }
  385. if metadatasConflictAlreadyExistingFiles.count == metadatasUploadInConflict.count {
  386. switchAlreadyExistingFiles.isOn = true
  387. } else {
  388. switchAlreadyExistingFiles.isOn = false
  389. }
  390. canContinue()
  391. }
  392. func canContinue() {
  393. var result = true
  394. for metadata in metadatasUploadInConflict {
  395. if !metadatasConflictNewFiles.contains(metadata.ocId) && !metadatasConflictAlreadyExistingFiles.contains(metadata.ocId) {
  396. result = false
  397. }
  398. }
  399. if result {
  400. buttonContinue.isEnabled = true
  401. buttonContinue.setTitleColor(NCBrandColor.shared.textColor, for: .normal)
  402. } else {
  403. buttonContinue.isEnabled = false
  404. buttonContinue.setTitleColor(NCBrandColor.shared.textColor2, for: .normal)
  405. }
  406. }
  407. }
  408. // MARK: - UIViewControllerRepresentable
  409. struct UploadConflictView: UIViewControllerRepresentable {
  410. typealias UIViewControllerType = NCCreateFormUploadConflict
  411. var delegate: NCCreateFormUploadConflictDelegate
  412. var serverUrl: String
  413. var metadatasUploadInConflict: [tableMetadata]
  414. var metadatasNOConflict: [tableMetadata]
  415. func makeUIViewController(context: Context) -> UIViewControllerType {
  416. let storyboard = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil)
  417. let viewController = storyboard.instantiateInitialViewController() as? NCCreateFormUploadConflict
  418. viewController?.delegate = delegate
  419. viewController?.textLabelDetailNewFile = NSLocalizedString("_now_", comment: "")
  420. viewController?.serverUrl = serverUrl
  421. viewController?.metadatasUploadInConflict = metadatasUploadInConflict
  422. viewController?.metadatasNOConflict = metadatasNOConflict
  423. return viewController!
  424. }
  425. func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }
  426. }