NCChatFileStatus.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  3. // SPDX-License-Identifier: GPL-3.0-or-later
  4. //
  5. import Foundation
  6. @objcMembers public class NCChatFileStatus: NSObject {
  7. public var fileId: String
  8. public var fileName: String
  9. public var filePath: String
  10. public var fileLocalPath: String?
  11. public var isDownloading: Bool = false
  12. public var canReportProgress: Bool = false
  13. public var downloadProgress: Float = 0
  14. init(fileId: String, fileName: String, filePath: String) {
  15. self.fileId = fileId
  16. self.fileName = fileName
  17. self.filePath = filePath
  18. }
  19. public func isStatus(for messageFileParameter: NCMessageFileParameter) -> Bool {
  20. return self.fileId == messageFileParameter.parameterId && self.filePath == messageFileParameter.path
  21. }
  22. public static func getStatus(from notification: Notification, for messageFileParameter: NCMessageFileParameter) -> NCChatFileStatus? {
  23. guard let receivedStatus = notification.userInfo?["fileStatus"] as? NCChatFileStatus,
  24. receivedStatus.isStatus(for: messageFileParameter)
  25. else { return nil }
  26. return receivedStatus
  27. }
  28. }