Skip to content

Commit b5ae803

Browse files
committed
Fix incorrect display of unavailable attachments in chat
1 parent fdb0179 commit b5ae803

File tree

8 files changed

+33
-10
lines changed

8 files changed

+33
-10
lines changed

Adamant/Modules/Chat/View/Managers/ChatAction.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ enum ChatAction {
2424
case cancelUploading(messageId: String)
2525
case autoDownloadContentIfNeeded(messageId: String, files: [ChatFile])
2626
case forceDownloadAllFiles(messageId: String, files: [ChatFile])
27+
case showDialog(title: String)
2728
}

Adamant/Modules/Chat/View/Managers/ChatDataSourceManager.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ extension ChatDataSourceManager {
223223
)
224224
case let .forceDownloadAllFiles(messageId, files):
225225
viewModel.forceDownloadAllFiles(messageId: messageId, files: files)
226+
case let .showDialog(title):
227+
viewModel.dialog.send(.alert(title))
226228
}
227229
}
228230
}

Adamant/Modules/Chat/View/Subviews/ChatMedia/Container/ChatMediaContainerView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ final class ChatMediaContainerView: UIView {
154154
actionHandler(.openFile(messageId: model.id, file: file))
155155
return
156156
}
157+
158+
if model.status == .unableToDownload {
159+
actionHandler(.showDialog(title: FileManagerError.unableToDownloadCorrupted.localizedDescription))
160+
return
161+
}
157162

158163
guard case .needToDownload = model.status else {
159164
return

Adamant/Services/FilesNetworkManager/Models/FileManagerError.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,25 @@ enum FileManagerError: Error {
1818
case cantUploadFile
1919
case cantEncryptFile
2020
case cantDecryptFile
21+
case unableToDownloadCorrupted
2122
case apiError(error: ApiServiceError)
2223
}
2324

2425
extension FileManagerError: LocalizedError {
2526
var errorDescription: String? {
2627
switch self {
27-
case .cantDownloadFile:
28-
return .localized("FileManagerError.CantDownloadFile")
29-
case .cantUploadFile:
30-
return .localized("FileManagerError.CantUploadFile")
31-
case .cantEncryptFile:
32-
return .localized("FileManagerError.CantEncryptFile")
33-
case .cantDecryptFile:
34-
return .localized("FileManagerError.CantDecryptFile")
35-
case let .apiError(error: error):
36-
return error.localizedDescription
28+
case .cantDownloadFile:
29+
return .localized("FileManagerError.CantDownloadFile")
30+
case .cantUploadFile:
31+
return .localized("FileManagerError.CantUploadFile")
32+
case .cantEncryptFile:
33+
return .localized("FileManagerError.CantEncryptFile")
34+
case .cantDecryptFile:
35+
return .localized("FileManagerError.CantDecryptFile")
36+
case .unableToDownloadCorrupted:
37+
return .localized("FileManagerError.UnableToDownloadCorrupted")
38+
case let .apiError(error: error):
39+
return error.localizedDescription
3740
}
3841
}
3942
}

CommonKit/Sources/CommonKit/Assets/Localization/de.lproj/Localizable.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,9 @@
13541354
/* FileManager error 'Can't decrypt file' */
13551355
"FileManagerError.CantDecryptFile" = "Datei kann nicht entschlüsselt werden";
13561356

1357+
/* FileManager error 'Unable to download corrupted file' */
1358+
"FileManagerError.UnableToDownloadCorrupted" = "Download nicht möglich.\nDatei(en) könnten beschädigt sein.";
1359+
13571360
/* File validation error 'Too many files' */
13581361
"FileValidationError.TooManyFiles" = "Zu viele Dateien. Höchstens erlaubt: %lld";
13591362

CommonKit/Sources/CommonKit/Assets/Localization/en.lproj/Localizable.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,9 @@
13301330
/* FileManager error 'Can't decrypt file' */
13311331
"FileManagerError.CantDecryptFile" = "Can't decrypt file";
13321332

1333+
/* FileManager error 'Unable to download corrupted file' */
1334+
"FileManagerError.UnableToDownloadCorrupted" = "Unable to download.\nFile(s) could be corrupted.";
1335+
13331336
/* File validation error 'Too many files' */
13341337
"FileValidationError.TooManyFiles" = "Too many files. Maximum allowed: %lld";
13351338

CommonKit/Sources/CommonKit/Assets/Localization/ru.lproj/Localizable.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,9 @@
13341334
/* FileManager error 'Can't decrypt file' */
13351335
"FileManagerError.CantDecryptFile" = "Не удалось расшифровать файл";
13361336

1337+
/* FileManager error 'Unable to download corrupted file' */
1338+
"FileManagerError.UnableToDownloadCorrupted" = "Невозможно загрузить.\nФайл(ы) могут быть повреждены.";
1339+
13371340
/* File validation error 'Too many files' */
13381341
"FileValidationError.TooManyFiles" = "Превышено максимально допустимое количество файлов (%lld)";
13391342

CommonKit/Sources/CommonKit/Assets/Localization/zh.lproj/Localizable.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,9 @@
13251325
/* FileManager error 'Can't decrypt file' */
13261326
"FileManagerError.CantDecryptFile" = "无法解密文件";
13271327

1328+
/* FileManager error 'Unable to download corrupted file' */
1329+
"FileManagerError.UnableToDownloadCorrupted" = "无法下载。\n文件可能已损坏。";
1330+
13281331
/* File validation error 'Too many files' */
13291332
"FileValidationError.TooManyFiles" = "文件太多。 最大允许:%lld";
13301333

0 commit comments

Comments
 (0)