Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(MessageView): Add message on error fetching #1005

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions Mail/Views/Thread/MessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ struct MessageView: View {
/// True once we finished preprocessing the content
@State var isMessagePreprocessed = false

@State private var isShowingErrorLoading = false

/// The cancellable task used to preprocess the content
@State var preprocessing: Task<Void, Never>?

Expand Down Expand Up @@ -88,14 +90,22 @@ struct MessageView: View {
.padding(.top, value: .medium)
}

MessageBodyView(
isMessagePreprocessed: isMessagePreprocessed,
presentableBody: $presentableBody,
blockRemoteContent: isRemoteContentBlocked,
displayContentBlockedActionView: $displayContentBlockedActionView,
messageUid: message.uid
)
.padding(.top, value: .regular)
if isShowingErrorLoading {
Text(MailResourcesStrings.Localizable.errorLoadingMessage)
.textStyle(.bodySmallItalicSecondary)
.padding(.top, value: .regular)
.padding(.horizontal, value: .regular)
.frame(maxWidth: .infinity, alignment: .leading)
} else {
MessageBodyView(
isMessagePreprocessed: isMessagePreprocessed,
presentableBody: $presentableBody,
blockRemoteContent: isRemoteContentBlocked,
displayContentBlockedActionView: $displayContentBlockedActionView,
messageUid: message.uid
)
.padding(.top, value: .regular)
}
}
}
.padding(.vertical, value: .regular)
Expand Down Expand Up @@ -137,6 +147,8 @@ struct MessageView: View {
} catch let error as MailApiError where error == .apiMessageNotFound {
snackbarPresenter.show(message: error.localizedDescription)
try await mailboxManager.refreshFolder(from: [message])
} catch {
isShowingErrorLoading = true
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions MailCore/Utils/MailTextStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public struct MailTextStyle {
color: MailResourcesAsset.textSecondaryColor
)

public static let bodySmallItalicSecondary = MailTextStyle(
font: .system(size: 14).italic(),
color: MailResourcesAsset.textSecondaryColor
)

public static let bodySmallTertiary = MailTextStyle(
font: .system(size: 14),
color: MailResourcesAsset.textTertiaryColor
Expand Down
81 changes: 78 additions & 3 deletions MailResources/Localizable/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Release: Working copy
* Locale: de, German
* Tagged: ios
* Exported by: Philippe Weidmann
* Exported at: Wed, 13 Sep 2023 10:20:38 +0200
* Exported by: Ambroise Decouttere
* Exported at: Fri, 29 Sep 2023 10:01:40 +0200
*/

/* loco:6256793050618f7416758a32 */
Expand Down Expand Up @@ -468,7 +468,7 @@
"createFolderNoParent" = "Keine";

/* loco:62b1c2566ff2923a1a5b0832 */
"buttonCreate" = "erstellen.";
"buttonCreate" = "Erstellen";

/* loco:62b1d1ee36cd805389679933 */
"contentDescriptionIconStorage" = "Speicherstatus";
Expand Down Expand Up @@ -1279,3 +1279,78 @@

/* loco:65016e82bd99726dde081533 */
"noConnection" = "Keine Verbindung";

/* loco:65017fa44f4fa3e3b902d043 */
"aiPromptTitle" = "Schreibassistent";

/* loco:6501834aa4abf8d77708b7b5 */
"aiPromptTag" = "Beta";

/* loco:6501840ef58ecb8b620adb23 */
"aiPromptPlaceholder" = "Sagen Sie dem Schreibassistenten, was Sie schreiben wollen. Zum Beispiel: \"eine Dankes-E-Mail für ein Willkommensgeschenk\".";

/* loco:65019254a2948ddd0d0e0ca3 */
"aiPromptValidateButton" = "Erzeugen Sie";

/* loco:6502bdf0d8ec8382d70de1c7 */
"errorLoadingMessage" = "Diese Nachricht konnte nicht vom Server heruntergeladen werden.";

/* loco:6502fd61e3b907c3db020f92 */
"snackbarDeletedConversation" = "Das Gespräch existiert nicht mehr";

/* loco:65042259ab599c0ca6094172 */
"aiPromptGenerationLoader" = "Der Assistent schreibt";

/* loco:65081ae6a237c4d16909e463 */
"aiButtonRefine" = "Verfeinern";

/* loco:65081b4d5787de874c0dec32 */
"aiButtonInsert" = "Einfügen";

/* loco:650af993aaf29390e1022692 */
"aiReplacementDialogTitle" = "Bestehende Inhalte ersetzen?";

/* loco:650afa5b0b0204386e077c94 */
"aiReplacementDialogDescription" = "Möchten Sie den vorhandenen Inhalt durch den Vorschlag des Assistenten ersetzen?";

/* loco:650afb3b15bedc19200ab182 */
"aiReplacementDialogPositiveButton" = "Ersetzen";

/* loco:650afca41010feb5710a0b45 */
"aiReplacementDialogDoNotShowAgain" = "Diese Nachricht nicht mehr anzeigen";

/* loco:65129af16ad732b0790e61c2 */
"aiErrorTooManyRequests" = "Es scheint, dass Sie in kurzer Zeit zu viele Suchanfragen gestellt haben.\n\nBitte haben Sie einen Moment Geduld.";

/* loco:65129ba24376b5dd8c04b6a2 */
"aiErrorMaxTokenReached" = "Ihre Anfrage ist zu lang, bitte versuchen Sie es noch einmal in einem kürzeren Format.";

/* loco:65129c4db1cb64db900f6a02 */
"aiErrorUnknown" = "Es ist ein Fehler aufgetreten. Wenn dieser Fehler weiterhin auftritt, wenden Sie sich bitte an unseren Support.\n\nVielen Dank für Ihre Geduld.";

/* loco:65129d1caf62abf5d40d9082 */
"aiButtonRetry" = "Wiederholen";

/* loco:651549fc352ff768af054453 */
"aiMenuEditRequest" = "Meine Anfrage bearbeiten";

/* loco:65154a444e2a92186f026aa3 */
"aiMenuRegenerate" = "Eine Antwort neu generieren";

/* loco:65154a5b5740266cf70c84a2 */
"aiMenuShorten" = "Kürzen Sie";

/* loco:65154a780b64dfbdde02ac45 */
"aiMenuExpand" = "Erweitern Sie";

/* loco:65154b23fc895ced1501cde2 */
"aiMenuSeriousWriting" = "Seriöses Schreiben";

/* loco:65154b39664dcac1df0d7492 */
"aiMenuFriendlyWriting" = "Freundliches Schreiben";

/* loco:651584a40e0b9f6c680ced32 */
"aiDiscoveryTitle" = "Schreiben Sie Ihre E-Mails mit AI";

/* loco:651587be8ddc30b025013c52 */
"aiDiscoveryDescription" = "Vereinfachen Sie das Schreiben von Nachrichten mit künstlicher Intelligenz.";
79 changes: 77 additions & 2 deletions MailResources/Localizable/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Release: Working copy
* Locale: en, English
* Tagged: ios
* Exported by: Philippe Weidmann
* Exported at: Wed, 13 Sep 2023 10:20:38 +0200
* Exported by: Ambroise Decouttere
* Exported at: Fri, 29 Sep 2023 10:01:40 +0200
*/

/* loco:6256793050618f7416758a32 */
Expand Down Expand Up @@ -1279,3 +1279,78 @@

/* loco:65016e82bd99726dde081533 */
"noConnection" = "No connection";

/* loco:65017fa44f4fa3e3b902d043 */
"aiPromptTitle" = "Writing assistant";

/* loco:6501834aa4abf8d77708b7b5 */
"aiPromptTag" = "Beta";

/* loco:6501840ef58ecb8b620adb23 */
"aiPromptPlaceholder" = "Tell the writing assistant what you want to write. For example, \"a thank-you email for a welcome gift\".";

/* loco:65019254a2948ddd0d0e0ca3 */
"aiPromptValidateButton" = "Generate";

/* loco:6502bdf0d8ec8382d70de1c7 */
"errorLoadingMessage" = "This message could not be downloaded from the server.";

/* loco:6502fd61e3b907c3db020f92 */
"snackbarDeletedConversation" = "Conversation no longer exists";

/* loco:65042259ab599c0ca6094172 */
"aiPromptGenerationLoader" = "The assistant is writing";

/* loco:65081ae6a237c4d16909e463 */
"aiButtonRefine" = "Refine";

/* loco:65081b4d5787de874c0dec32 */
"aiButtonInsert" = "Insert";

/* loco:650af993aaf29390e1022692 */
"aiReplacementDialogTitle" = "Replace already existing content?";

/* loco:650afa5b0b0204386e077c94 */
"aiReplacementDialogDescription" = "Do you want to replace existing content by the assistant’s proposition?";

/* loco:650afb3b15bedc19200ab182 */
"aiReplacementDialogPositiveButton" = "Replace";

/* loco:650afca41010feb5710a0b45 */
"aiReplacementDialogDoNotShowAgain" = "Do not show this again";

/* loco:65129af16ad732b0790e61c2 */
"aiErrorTooManyRequests" = "It seems you’ve made too many requests in a short amount of time.\n\nPlease wait a few moments.";

/* loco:65129ba24376b5dd8c04b6a2 */
"aiErrorMaxTokenReached" = "Your request is too long, please try again in a shorter format.";

/* loco:65129c4db1cb64db900f6a02 */
"aiErrorUnknown" = "An error has occurred. If this error persists, please contact our helpdesk.\n\nThank you for your patience.";

/* loco:65129d1caf62abf5d40d9082 */
"aiButtonRetry" = "Retry";

/* loco:651549fc352ff768af054453 */
"aiMenuEditRequest" = "Edit my request";

/* loco:65154a444e2a92186f026aa3 */
"aiMenuRegenerate" = "Regenerate a response";

/* loco:65154a5b5740266cf70c84a2 */
"aiMenuShorten" = "Shorten";

/* loco:65154a780b64dfbdde02ac45 */
"aiMenuExpand" = "Expand";

/* loco:65154b23fc895ced1501cde2 */
"aiMenuSeriousWriting" = "Serious writing";

/* loco:65154b39664dcac1df0d7492 */
"aiMenuFriendlyWriting" = "Friendly writing";

/* loco:651584a40e0b9f6c680ced32 */
"aiDiscoveryTitle" = "Write your emails using AI";

/* loco:651587be8ddc30b025013c52 */
"aiDiscoveryDescription" = "Simplify your message writing with Artificial Intelligence.";
79 changes: 77 additions & 2 deletions MailResources/Localizable/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Release: Working copy
* Locale: es, Spanish
* Tagged: ios
* Exported by: Philippe Weidmann
* Exported at: Wed, 13 Sep 2023 10:20:38 +0200
* Exported by: Ambroise Decouttere
* Exported at: Fri, 29 Sep 2023 10:01:40 +0200
*/

/* loco:6256793050618f7416758a32 */
Expand Down Expand Up @@ -1279,3 +1279,78 @@

/* loco:65016e82bd99726dde081533 */
"noConnection" = "Sin conexión";

/* loco:65017fa44f4fa3e3b902d043 */
"aiPromptTitle" = "Asistente de redacción";

/* loco:6501834aa4abf8d77708b7b5 */
"aiPromptTag" = "Beta";

/* loco:6501840ef58ecb8b620adb23 */
"aiPromptPlaceholder" = "Dígale al asistente de redacción lo que quiere escribir. Por ejemplo, \"un correo electrónico de agradecimiento por un regalo de bienvenida\".";

/* loco:65019254a2948ddd0d0e0ca3 */
"aiPromptValidateButton" = "Genere";

/* loco:6502bdf0d8ec8382d70de1c7 */
"errorLoadingMessage" = "Este mensaje no se ha podido descargar del servidor.";

/* loco:6502fd61e3b907c3db020f92 */
"snackbarDeletedConversation" = "La conversación ya no existe";

/* loco:65042259ab599c0ca6094172 */
"aiPromptGenerationLoader" = "El asistente está escribiendo";

/* loco:65081ae6a237c4d16909e463 */
"aiButtonRefine" = "Afinar";

/* loco:65081b4d5787de874c0dec32 */
"aiButtonInsert" = "Inserte";

/* loco:650af993aaf29390e1022692 */
"aiReplacementDialogTitle" = "¿Reemplazar el contenido existente?";

/* loco:650afa5b0b0204386e077c94 */
"aiReplacementDialogDescription" = "¿Desea sustituir el contenido existente por la propuesta del asistente?";

/* loco:650afb3b15bedc19200ab182 */
"aiReplacementDialogPositiveButton" = "Sustituir";

/* loco:650afca41010feb5710a0b45 */
"aiReplacementDialogDoNotShowAgain" = "No volver a mostrar este mensaje";

/* loco:65129af16ad732b0790e61c2 */
"aiErrorTooManyRequests" = "Parece que ha realizado demasiadas solicitudes en un corto espacio de tiempo.\n\nPor favor, espere unos momentos.";

/* loco:65129ba24376b5dd8c04b6a2 */
"aiErrorMaxTokenReached" = "Su solicitud es demasiado larga. Por favor, inténtelo de nuevo en un formato más corto.";

/* loco:65129c4db1cb64db900f6a02 */
"aiErrorUnknown" = "Se ha producido un error. Si este error persiste, póngase en contacto con nuestro servicio de asistencia.\n\nGracias por su paciencia.";

/* loco:65129d1caf62abf5d40d9082 */
"aiButtonRetry" = "Reintentar";

/* loco:651549fc352ff768af054453 */
"aiMenuEditRequest" = "Editar mi solicitud";

/* loco:65154a444e2a92186f026aa3 */
"aiMenuRegenerate" = "Regenerar una respuesta";

/* loco:65154a5b5740266cf70c84a2 */
"aiMenuShorten" = "Acortar";

/* loco:65154a780b64dfbdde02ac45 */
"aiMenuExpand" = "Ampliar";

/* loco:65154b23fc895ced1501cde2 */
"aiMenuSeriousWriting" = "Escritura seria";

/* loco:65154b39664dcac1df0d7492 */
"aiMenuFriendlyWriting" = "Escritura amistosa";

/* loco:651584a40e0b9f6c680ced32 */
"aiDiscoveryTitle" = "Escriba sus correos electrónicos utilizando IA";

/* loco:651587be8ddc30b025013c52 */
"aiDiscoveryDescription" = "Simplifique la redacción de sus mensajes con Inteligencia Artificial.";
Loading
Loading