Skip to content

Commit 4481313

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

8 files changed

Lines changed: 31 additions & 110 deletions

File tree

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: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,36 +1354,5 @@
13541354
/* FileManager error 'Can't decrypt file' */
13551355
"FileManagerError.CantDecryptFile" = "Datei kann nicht entschlüsselt werden";
13561356

1357-
/* File validation error 'Too many files' */
1358-
"FileValidationError.TooManyFiles" = "Zu viele Dateien. Höchstens erlaubt: %lld";
1359-
1360-
/* File validation error 'File size exceeds limit' */
1361-
"FileValidationError.FileSizeExceedsLimit" = "Dateigröße überschreitet das Limit. Maximal erlaubt: %lld MB";
1362-
1363-
/* File validation error 'File not found' */
1364-
"FileValidationError.FileNotFound" = "Datei nicht gefunden";
1365-
1366-
/* File picker error 'Cant select file' */
1367-
"FileValidationError.CantSelectFile" = "Datei kann nicht ausgewählt werden: %@";
1368-
1369-
/* Chat drop view title */
1370-
"Chat.Drop.Title" = "Dateien hier ablegen";
1371-
1372-
/* Chat unknown */
1373-
"Chat.unknown.title" = "Unbekannt";
1374-
1375-
/* No active nodes */
1376-
"Chat.Alert.Title.NoActiveNodes" = "Keine aktiven ADM-Knoten";
1377-
"Chat.Alert.NoActiveNodes" = "Es können keine neuen Nachrichten angefordert werden - Keine aktiven ADM-Blockchain-Knoten. Da Sie einige von ihnen deaktiviert haben, sollten Sie die Knotenliste überprüfen.";
1378-
1379-
/* Timestamp in the future */
1380-
"Chat.Alert.Title.TimestampIsInTheFuture" = "Gerätezeit prüfen";
1381-
"Chat.Alert.TimestampIsInTheFuture" = "Es können keine neuen Nachrichten angefordert werden - keine aktiven ADM-Blockchain-Knoten. Da Sie einige von ihnen deaktiviert haben, sollten Sie die Knotenliste überprüfen.";
1382-
"Chat.Alert.TimeSettings" = "Zeiteinstellung";
1383-
1384-
/* Review Nodes List */
1385-
"Chat.Alert.ReviewNodesList" = "ADM-Knotenliste überprüfen";
1386-
1387-
"Chat.Timestamp.InFuture.Error" = "Ein Netzwerkknoten hat die Nachricht abgelehnt, weil die Zeit auf Ihrem Gerät vorgeht.\nÜberprüfen Sie die Uhrzeit des Geräts oder versuchen Sie erneut, eine Nachricht zu senden.";
1388-
1389-
"LearnMore" = "Lernen Sie mehr";
1357+
/* FileManager error 'Unable to download corrupted file' */
1358+
"FileManagerError.UnableToDownloadCorrupted" = "Download nicht möglich.\nDatei(en) könnten beschädigt sein.";

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

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

1333-
/* File validation error 'Too many files' */
1334-
"FileValidationError.TooManyFiles" = "Too many files. Maximum allowed: %lld";
1335-
1336-
/* File validation error 'File size exceeds limit' */
1337-
"FileValidationError.FileSizeExceedsLimit" = "Send files up to %lld MB";
1338-
1339-
/* File validation error 'File not found' */
1340-
"FileValidationError.FileNotFound" = "File not found";
1341-
1342-
/* File picker error 'Cant select file' */
1343-
"FileValidationError.CantSelectFile" = "Can't select file: %@";
1344-
1345-
/* Chat drop view title */
1346-
"Chat.Drop.Title" = "Drop files here";
1347-
1348-
/* Chat unknown */
1349-
"Chat.unknown.title" = "Unknown";
1350-
1351-
/* No active nodes */
1352-
"Chat.Alert.Title.NoActiveNodes" = "No active ADM nodes";
1353-
"Chat.Alert.NoActiveNodes" = "Unable to request new messages—No active ADM blockchain nodes. As you’ve deactivated some of them, consider reviewing the node list.";
1354-
1355-
/* Timestamp in the future */
1356-
"Chat.Alert.Title.TimestampIsInTheFuture" = "Check device time";
1357-
"Chat.Alert.TimestampIsInTheFuture" = "A network node rejected the message because the time on your device is ahead. Check the device's time or try sending a message again.";
1358-
"Chat.Alert.TimeSettings" = "Time setting";
1359-
1360-
/* Review Nodes List */
1361-
"Chat.Alert.ReviewNodesList" = "Review ADM node list";
1362-
1363-
"Chat.Timestamp.InFuture.Error" = "A network node rejected the message because the time on your device is ahead.\nCheck the device's time or try sending a message again.";
1364-
1365-
"LearnMore" = "Learn more";
1333+
/* FileManager error 'Unable to download corrupted file' */
1334+
"FileManagerError.UnableToDownloadCorrupted" = "Unable to download.\nFile(s) could be corrupted.";

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

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,38 +1332,7 @@
13321332
"FileManagerError.CantEncryptFile" = "Не удалось зашифровать файл";
13331333

13341334
/* FileManager error 'Can't decrypt file' */
1335-
"FileManagerError.CantDecryptFile" = "Не удалось расшифровать файл";
1335+
"FileManagerError.CantDecryptFile" = "Не удается расшифровать файл";
13361336

1337-
/* File validation error 'Too many files' */
1338-
"FileValidationError.TooManyFiles" = "Превышено максимально допустимое количество файлов (%lld)";
1339-
1340-
/* File validation error 'File size exceeds limit' */
1341-
"FileValidationError.FileSizeExceedsLimit" = "Превышен размер файла. Отправляйте файлы до %lld МБ";
1342-
1343-
/* File validation error 'File not found' */
1344-
"FileValidationError.FileNotFound" = "Файл не найден";
1345-
1346-
/* File picker error 'Cant select file' */
1347-
"FileValidationError.CantSelectFile" = "Невозможно выбрать файл: %@";
1348-
1349-
/* Chat drop view title */
1350-
"Chat.Drop.Title" = "Перетащите файлы сюда";
1351-
1352-
/* Chat unknown */
1353-
"Chat.unknown.title" = "Неизвестный";
1354-
1355-
/* No active nodes */
1356-
"Chat.Alert.Title.NoActiveNodes" = "Нет активных узлов ADM";
1357-
"Chat.Alert.NoActiveNodes" = "Не удается получить новые сообщения — нет активных узлов блокчейна ADM. Поскольку вы отключили некоторые из них, посмотрите список узлов еще раз.";
1358-
1359-
/* Timestamp in the future */
1360-
"Chat.Alert.Title.TimestampIsInTheFuture" = "Проверьте время на устройстве";
1361-
"Chat.Alert.TimestampIsInTheFuture" = "Узел сети отклонил сообщение, потому что время на вашем устройстве спешит. Проверьте время на устройстве или попробуйте отправить сообщение снова.";
1362-
"Chat.Alert.TimeSettings" = "Настроить время";
1363-
1364-
/* Review Nodes List */
1365-
"Chat.Alert.ReviewNodesList" = "К списку узлов ADM";
1366-
1367-
"Chat.Timestamp.InFuture.Error" = "Узел сети отклонил сообщение, потому что время на вашем устройстве спешит.\nПроверьте время на устройстве или попробуйте отправить сообщение снова.";
1368-
1369-
"LearnMore" = "Узнать больше";
1337+
/* FileManager error 'Unable to download corrupted file' */
1338+
"FileManagerError.UnableToDownloadCorrupted" = "Невозможно загрузить.\nФайл(ы) могут быть повреждены.";

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,3 +1358,6 @@
13581358
"Chat.Timestamp.InFuture.Error" = "由于您设备上的时间超前,网络节点拒绝了信息。\n请检查设备的时间或再次尝试发送信息。";
13591359

13601360
"LearnMore" = "了解更多";
1361+
1362+
/* FileManager error 'Unable to download corrupted file' */
1363+
"FileManagerError.UnableToDownloadCorrupted" = "无法下载。\n文件可能已损坏。"";

0 commit comments

Comments
 (0)