NCActivity.swift 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. //
  2. // NCActivity.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 17/01/2019.
  6. // Copyright © 2019 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 SwiftRichString
  25. import NCCommunication
  26. class NCActivity: UIViewController, NCEmptyDataSetDelegate {
  27. @IBOutlet weak var tableView: UITableView!
  28. private let appDelegate = UIApplication.shared.delegate as! AppDelegate
  29. var emptyDataSet: NCEmptyDataSet?
  30. var allActivities: [tableActivity] = []
  31. var filterActivities: [tableActivity] = []
  32. var sectionDate: [Date] = []
  33. var insets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
  34. var didSelectItemEnable: Bool = true
  35. var filterFileId: String?
  36. var objectType: String?
  37. var canFetchActivity = true
  38. var dateAutomaticFetch : Date?
  39. // MARK: - View Life Cycle
  40. override func viewDidLoad() {
  41. super.viewDidLoad()
  42. self.navigationController?.navigationBar.prefersLargeTitles = true
  43. view.backgroundColor = NCBrandColor.shared.systemBackground
  44. self.title = NSLocalizedString("_activity_", comment: "")
  45. // Empty
  46. emptyDataSet = NCEmptyDataSet.init(view: tableView, offset: 0, delegate: self)
  47. tableView.allowsSelection = false
  48. tableView.separatorColor = UIColor.clear
  49. tableView.tableFooterView = UIView()
  50. tableView.contentInset = insets
  51. tableView.backgroundColor = NCBrandColor.shared.systemBackground
  52. NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
  53. changeTheming()
  54. }
  55. override func viewWillAppear(_ animated: Bool) {
  56. super.viewWillAppear(animated)
  57. appDelegate.activeViewController = self
  58. //
  59. NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
  60. }
  61. override func viewDidAppear(_ animated: Bool) {
  62. super.viewDidAppear(animated)
  63. initialize()
  64. }
  65. override func viewWillDisappear(_ animated: Bool) {
  66. super.viewWillDisappear(animated)
  67. NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
  68. }
  69. // MARK: - NotificationCenter
  70. @objc func initialize() {
  71. loadDataSource()
  72. loadActivity(idActivity: 0)
  73. }
  74. @objc func changeTheming() {
  75. tableView.reloadData()
  76. }
  77. // MARK: - Empty
  78. func emptyDataSetView(_ view: NCEmptyView) {
  79. view.emptyImage.image = UIImage.init(named: "bolt")?.image(color: .gray, size: UIScreen.main.bounds.width)
  80. view.emptyTitle.text = NSLocalizedString("_no_activity_", comment: "")
  81. view.emptyDescription.text = ""
  82. }
  83. }
  84. class activityTableViewCell: UITableViewCell, NCCellProtocol {
  85. private let appDelegate = UIApplication.shared.delegate as! AppDelegate
  86. @IBOutlet weak var collectionView: UICollectionView!
  87. @IBOutlet weak var icon: UIImageView!
  88. @IBOutlet weak var avatar: UIImageView!
  89. @IBOutlet weak var subject: UILabel!
  90. @IBOutlet weak var subjectTrailingConstraint: NSLayoutConstraint!
  91. @IBOutlet weak var collectionViewHeightConstraint: NSLayoutConstraint!
  92. private var user: String = ""
  93. var idActivity: Int = 0
  94. var account: String = ""
  95. var activityPreviews: [tableActivityPreview] = []
  96. var didSelectItemEnable: Bool = true
  97. var viewController: UIViewController? = nil
  98. var fileAvatarImageView: UIImageView? {
  99. get {
  100. return avatar
  101. }
  102. }
  103. var fileObjectId: String? {
  104. get {
  105. return nil
  106. }
  107. }
  108. var filePreviewImageView: UIImageView? {
  109. get {
  110. return nil
  111. }
  112. }
  113. var fileUser: String? {
  114. get {
  115. return user
  116. }
  117. set {
  118. user = newValue ?? ""
  119. }
  120. }
  121. override func awakeFromNib() {
  122. super.awakeFromNib()
  123. collectionView.delegate = self
  124. collectionView.dataSource = self
  125. }
  126. }
  127. // MARK: - Table View
  128. extension NCActivity: UITableViewDelegate {
  129. func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
  130. return 120
  131. }
  132. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  133. return 60
  134. }
  135. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  136. return UITableView.automaticDimension
  137. }
  138. func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
  139. let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 60))
  140. view.backgroundColor = .clear
  141. let label = UILabel()
  142. label.font = UIFont.boldSystemFont(ofSize: 13)
  143. label.textColor = NCBrandColor.shared.label
  144. label.text = CCUtility.getTitleSectionDate(sectionDate[section])
  145. label.textAlignment = .center
  146. label.layer.cornerRadius = 11
  147. label.layer.masksToBounds = true
  148. label.layer.backgroundColor = UIColor(red: 152.0/255.0, green: 167.0/255.0, blue: 181.0/255.0, alpha: 0.8).cgColor
  149. let widthFrame = label.intrinsicContentSize.width + 30
  150. let xFrame = tableView.bounds.width / 2 - widthFrame / 2
  151. label.frame = CGRect(x: xFrame, y: 10, width: widthFrame, height: 22)
  152. view.addSubview(label)
  153. return view
  154. }
  155. }
  156. extension NCActivity: UITableViewDataSource {
  157. func numberOfSections(in tableView: UITableView) -> Int {
  158. return sectionDate.count
  159. }
  160. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  161. let numberItems = getTableActivitiesFromSection(section).count
  162. emptyDataSet?.numberOfItemsInSection(numberItems, section: section)
  163. return numberItems
  164. }
  165. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  166. if let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath) as? activityTableViewCell {
  167. let results = getTableActivitiesFromSection(indexPath.section)
  168. let activity = results[indexPath.row]
  169. var orderKeysId: [String] = []
  170. cell.idActivity = activity.idActivity
  171. cell.account = activity.account
  172. cell.avatar.image = nil
  173. cell.avatar.isHidden = true
  174. cell.subjectTrailingConstraint.constant = 10
  175. cell.didSelectItemEnable = self.didSelectItemEnable
  176. cell.subject.textColor = NCBrandColor.shared.label
  177. cell.viewController = self
  178. // icon
  179. if activity.icon.count > 0 {
  180. let fileNameIcon = (activity.icon as NSString).lastPathComponent
  181. let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + fileNameIcon
  182. if FileManager.default.fileExists(atPath: fileNameLocalPath) {
  183. if let image = UIImage(contentsOfFile: fileNameLocalPath) { cell.icon.image = image }
  184. } else {
  185. NCCommunication.shared.downloadContent(serverUrl: activity.icon) { (account, data, errorCode, errorMessage) in
  186. if errorCode == 0 {
  187. do {
  188. try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
  189. tableView.reloadData()
  190. } catch { return }
  191. }
  192. }
  193. }
  194. }
  195. // avatar
  196. if activity.user.count > 0 && activity.user != appDelegate.userId {
  197. cell.subjectTrailingConstraint.constant = 50
  198. cell.avatar.isHidden = false
  199. cell.fileUser = activity.user
  200. let fileName = String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + activity.user + ".png"
  201. NCOperationQueue.shared.downloadAvatar(user: activity.user, fileName: fileName, placeholder: UIImage(named: "avatar"), cell: cell, view: tableView)
  202. }
  203. // subject
  204. if activity.subjectRich.count > 0 {
  205. var subject = activity.subjectRich
  206. var keys: [String] = []
  207. if let regex = try? NSRegularExpression(pattern: "\\{[a-z0-9]+\\}", options: .caseInsensitive) {
  208. let string = subject as NSString
  209. keys = regex.matches(in: subject, options: [], range: NSRange(location: 0, length: string.length)).map {
  210. string.substring(with: $0.range).replacingOccurrences(of: "[\\{\\}]", with: "", options: .regularExpression)
  211. }
  212. }
  213. for key in keys {
  214. if let result = NCManageDatabase.shared.getActivitySubjectRich(account: appDelegate.account, idActivity: activity.idActivity, key: key) {
  215. orderKeysId.append(result.id)
  216. subject = subject.replacingOccurrences(of: "{\(key)}", with: "<bold>" + result.name + "</bold>")
  217. }
  218. }
  219. let normal = Style {
  220. $0.font = UIFont.systemFont(ofSize: cell.subject.font.pointSize)
  221. $0.lineSpacing = 1.5
  222. }
  223. let bold = Style { $0.font = UIFont.systemFont(ofSize: cell.subject.font.pointSize, weight: .bold) }
  224. let date = Style { $0.font = UIFont.systemFont(ofSize: cell.subject.font.pointSize - 3)
  225. $0.color = UIColor.lightGray
  226. }
  227. subject = subject + "\n" + "<date>" + CCUtility.dateDiff(activity.date as Date) + "</date>"
  228. cell.subject.attributedText = subject.set(style: StyleGroup(base: normal, ["bold": bold, "date": date]))
  229. }
  230. // CollectionView
  231. cell.activityPreviews = NCManageDatabase.shared.getActivityPreview(account: activity.account, idActivity: activity.idActivity, orderKeysId: orderKeysId)
  232. if cell.activityPreviews.count == 0 {
  233. cell.collectionViewHeightConstraint.constant = 0
  234. } else {
  235. cell.collectionViewHeightConstraint.constant = 60
  236. }
  237. cell.collectionView.reloadData()
  238. return cell
  239. }
  240. return UITableViewCell()
  241. }
  242. }
  243. /*
  244. extension NCActivity: UITableViewDataSourcePrefetching {
  245. func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath]) {
  246. let section = indexPaths.last?.section ?? 0
  247. let row = indexPaths.last?.row ?? 0
  248. let lastSection = self.sectionDate.count - 1
  249. let lastRow = getTableActivitiesFromSection(section).count - 1
  250. if section == lastSection && row > lastRow - 1 {
  251. //loadActivity(idActivity: allActivities.last!.idActivity)
  252. }
  253. }
  254. func tableView(_ tableView: UITableView, cancelPrefetchingForRowsAt indexPaths: [IndexPath]) {
  255. //print("cancelPrefetchingForRowsAt \(indexPaths)")
  256. }
  257. }
  258. */
  259. // MARK: - ScrollView
  260. extension NCActivity: UIScrollViewDelegate {
  261. func scrollViewDidScroll(_ scrollView: UIScrollView) {
  262. if scrollView.contentSize.height - scrollView.contentOffset.y - scrollView.frame.height < 100 {
  263. if let activities = allActivities.last {
  264. loadActivity(idActivity: activities.idActivity)
  265. }
  266. }
  267. }
  268. }
  269. // MARK: - Collection View
  270. extension activityTableViewCell: UICollectionViewDelegate {
  271. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  272. // Select not permitted
  273. if !didSelectItemEnable {
  274. return
  275. }
  276. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as? activityCollectionViewCell
  277. let activityPreview = activityPreviews[indexPath.row]
  278. if activityPreview.view == "trashbin" {
  279. var responder: UIResponder? = collectionView
  280. while !(responder is UIViewController) {
  281. responder = responder?.next
  282. if nil == responder {
  283. break
  284. }
  285. }
  286. if (responder as? UIViewController)!.navigationController != nil {
  287. if let viewController = UIStoryboard.init(name: "NCTrash", bundle: nil).instantiateInitialViewController() as? NCTrash {
  288. if let result = NCManageDatabase.shared.getTrashItem(fileId: String(activityPreview.fileId), account: activityPreview.account) {
  289. viewController.blinkFileId = result.fileId
  290. viewController.trashPath = result.filePath
  291. (responder as? UIViewController)!.navigationController?.pushViewController(viewController, animated: true)
  292. } else {
  293. NCContentPresenter.shared.messageNotification("_error_", description: "_trash_file_not_found_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError)
  294. }
  295. }
  296. }
  297. return
  298. }
  299. if activityPreview.view == "files" && activityPreview.mimeType != "dir" {
  300. guard let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: activityPreview.account, idActivity: activityPreview.idActivity, id: String(activityPreview.fileId)) else {
  301. return
  302. }
  303. if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "fileId == %@", activitySubjectRich.id)) {
  304. if let filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView) {
  305. do {
  306. let attr = try FileManager.default.attributesOfItem(atPath: filePath)
  307. let fileSize = attr[FileAttributeKey.size] as! UInt64
  308. if fileSize > 0 {
  309. if let viewController = self.viewController {
  310. NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: cell?.imageView.image)
  311. }
  312. return
  313. }
  314. } catch {
  315. print("Error: \(error)")
  316. }
  317. }
  318. }
  319. var pathComponents = activityPreview.link.components(separatedBy: "?")
  320. pathComponents = pathComponents[1].components(separatedBy: "&")
  321. var serverUrlFileName = pathComponents[0].replacingOccurrences(of: "dir=", with: "").removingPercentEncoding!
  322. serverUrlFileName = appDelegate.urlBase + "/" + NCUtilityFileSystem.shared.getWebDAV(account: activityPreview.account) + serverUrlFileName + "/" + activitySubjectRich.name
  323. let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(activitySubjectRich.id, fileNameView: activitySubjectRich.name)!
  324. NCUtility.shared.startActivityIndicator(backgroundView: (appDelegate.window?.rootViewController?.view)!, blurEffect: true)
  325. NCCommunication.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { (_) in
  326. }, taskHandler: { (_) in
  327. }, progressHandler: { (_) in
  328. }) { (account, etag, date, lenght, allHeaderFields, error, errorCode, errorDescription) in
  329. if account == self.appDelegate.account && errorCode == 0 {
  330. let serverUrl = (serverUrlFileName as NSString).deletingLastPathComponent
  331. let fileName = (serverUrlFileName as NSString).lastPathComponent
  332. let serverUrlFileName = serverUrl + "/" + fileName
  333. NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName, account: activityPreview.account) { (account, metadata, errorCode, errorDescription) in
  334. NCUtility.shared.stopActivityIndicator()
  335. if account == self.appDelegate.account && errorCode == 0 {
  336. // move from id to oc:id + instanceid (ocId)
  337. let atPath = CCUtility.getDirectoryProviderStorage()! + "/" + activitySubjectRich.id
  338. let toPath = CCUtility.getDirectoryProviderStorage()! + "/" + metadata!.ocId
  339. CCUtility.moveFile(atPath: atPath, toPath: toPath)
  340. NCManageDatabase.shared.addMetadata(metadata!)
  341. if let viewController = self.viewController {
  342. NCViewer.shared.view(viewController: viewController, metadata: metadata!, metadatas: [metadata!], imageIcon: cell?.imageView.image)
  343. }
  344. }
  345. }
  346. } else {
  347. NCUtility.shared.stopActivityIndicator()
  348. }
  349. }
  350. }
  351. }
  352. }
  353. extension activityTableViewCell: UICollectionViewDataSource {
  354. func numberOfSections(in collectionView: UICollectionView) -> Int {
  355. return 1
  356. }
  357. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  358. return activityPreviews.count
  359. }
  360. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  361. let cell: activityCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as! activityCollectionViewCell
  362. cell.imageView.image = nil
  363. let activityPreview = activityPreviews[indexPath.row]
  364. let fileId = String(activityPreview.fileId)
  365. // Trashbin
  366. if activityPreview.view == "trashbin" {
  367. let source = activityPreview.source
  368. NCUtility.shared.convertSVGtoPNGWriteToUserData(svgUrlString: source, fileName: nil, width: 100, rewrite: false, account: appDelegate.account) { (imageNamePath) in
  369. if imageNamePath != nil {
  370. if let image = UIImage(contentsOfFile: imageNamePath!) {
  371. cell.imageView.image = image
  372. }
  373. } else {
  374. cell.imageView.image = UIImage.init(named: "file")
  375. }
  376. }
  377. } else {
  378. if activityPreview.isMimeTypeIcon {
  379. let source = activityPreview.source
  380. NCUtility.shared.convertSVGtoPNGWriteToUserData(svgUrlString: source, fileName: nil, width: 100, rewrite: false, account: appDelegate.account) { (imageNamePath) in
  381. if imageNamePath != nil {
  382. if let image = UIImage(contentsOfFile: imageNamePath!) {
  383. cell.imageView.image = image
  384. }
  385. } else {
  386. cell.imageView.image = UIImage.init(named: "file")
  387. }
  388. }
  389. } else {
  390. if let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: account, idActivity: idActivity, id: fileId) {
  391. let fileNamePath = CCUtility.getDirectoryUserData() + "/" + activitySubjectRich.name
  392. if FileManager.default.fileExists(atPath: fileNamePath) {
  393. if let image = UIImage(contentsOfFile: fileNamePath) {
  394. cell.imageView.image = image
  395. }
  396. } else {
  397. NCCommunication.shared.downloadPreview(fileNamePathOrFileId: activityPreview.source, fileNamePreviewLocalPath: fileNamePath, widthPreview: 0, heightPreview: 0, etag: nil, useInternalEndpoint: false) { (account, imagePreview, imageIcon, imageOriginal, etag, errorCode, errorDescription) in
  398. if errorCode == 0 && imagePreview != nil {
  399. self.collectionView.reloadData()
  400. }
  401. }
  402. }
  403. }
  404. }
  405. }
  406. return cell
  407. }
  408. }
  409. class activityCollectionViewCell: UICollectionViewCell {
  410. @IBOutlet weak var imageView: UIImageView!
  411. override func awakeFromNib() {
  412. super.awakeFromNib()
  413. }
  414. }
  415. extension activityTableViewCell: UICollectionViewDelegateFlowLayout {
  416. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
  417. return CGSize(width: 50, height: 50)
  418. }
  419. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
  420. return 20
  421. }
  422. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
  423. return UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
  424. }
  425. }
  426. // MARK: - NC API & Algorithm
  427. extension NCActivity {
  428. func loadDataSource() {
  429. sectionDate.removeAll()
  430. let activities = NCManageDatabase.shared.getActivity(predicate: NSPredicate(format: "account == %@", appDelegate.account), filterFileId: filterFileId)
  431. allActivities = activities.all
  432. filterActivities = activities.filter
  433. for tableActivity in filterActivities {
  434. guard let date = Calendar.current.date(from: Calendar.current.dateComponents([.year, .month, .day], from: tableActivity.date as Date)) else {
  435. continue
  436. }
  437. if !sectionDate.contains(date) {
  438. sectionDate.append(date)
  439. }
  440. }
  441. tableView.reloadData()
  442. }
  443. func getTableActivitiesFromSection(_ section: Int) -> [tableActivity] {
  444. let startDate = sectionDate[section]
  445. let endDate: Date = {
  446. let components = DateComponents(day: 1, second: -1)
  447. return Calendar.current.date(byAdding: components, to: startDate)!
  448. }()
  449. let activities = NCManageDatabase.shared.getActivity(predicate: NSPredicate(format: "account == %@ && date BETWEEN %@", appDelegate.account, [startDate, endDate]), filterFileId: filterFileId)
  450. return activities.filter
  451. }
  452. @objc func loadActivity(idActivity: Int) {
  453. if !canFetchActivity { return }
  454. canFetchActivity = false
  455. if idActivity > 0 {
  456. let height = self.tabBarController?.tabBar.frame.size.height ?? 0
  457. NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: height + 50, style: .gray)
  458. }
  459. NCCommunication.shared.getActivity(since: idActivity, limit: 200, objectId: filterFileId, objectType: objectType, previews: true) { (account, activities, errorCode, errorDescription) in
  460. if errorCode == 0 && account == self.appDelegate.account {
  461. NCManageDatabase.shared.addActivity(activities , account: account)
  462. }
  463. NCUtility.shared.stopActivityIndicator()
  464. if errorCode == NCGlobal.shared.errorNotModified {
  465. self.canFetchActivity = false
  466. } else {
  467. self.canFetchActivity = true
  468. }
  469. self.loadDataSource()
  470. }
  471. }
  472. }