diff --git a/Mail/Components/UnavailableMailboxListView.swift b/Mail/Components/UnavailableMailboxListView.swift index 8b44f2ed7e..dce7484adf 100644 --- a/Mail/Components/UnavailableMailboxListView.swift +++ b/Mail/Components/UnavailableMailboxListView.swift @@ -25,19 +25,9 @@ import RealmSwift import SwiftUI struct UnavailableMailboxListView: View { - @ObservedResults var passwordBlockedMailboxes: Results @ObservedResults var lockedMailboxes: Results init(currentUserId: Int) { - _passwordBlockedMailboxes = ObservedResults( - Mailbox.self, - configuration: { - @InjectService var mailboxInfosManager: MailboxInfosManager - return mailboxInfosManager.realmConfiguration - }(), - where: { UnavailableMailboxListView.filterPasswordBlockedMailboxes($0, for: currentUserId) }, - sortDescriptor: SortDescriptor(keyPath: \Mailbox.mailboxId) - ) _lockedMailboxes = ObservedResults( Mailbox.self, configuration: { @@ -51,16 +41,6 @@ struct UnavailableMailboxListView: View { var body: some View { VStack(alignment: .leading, spacing: IKPadding.huge) { - if !passwordBlockedMailboxes.isEmpty { - VStack(alignment: .leading, spacing: IKPadding.small) { - Text(MailResourcesStrings.Localizable.blockedPasswordTitle(passwordBlockedMailboxes.count)) - ForEach(passwordBlockedMailboxes) { mailbox in - MailboxCell(mailbox: mailbox) - .mailboxCellStyle(.blockedPassword) - } - } - } - if !lockedMailboxes.isEmpty { VStack(alignment: .leading, spacing: IKPadding.small) { Text(MailResourcesStrings.Localizable.lockedMailboxTitle(lockedMailboxes.count)) @@ -76,23 +56,13 @@ struct UnavailableMailboxListView: View { .padding(.top, IKPadding.large) } - private static func filterPasswordBlockedMailboxes(_ mailbox: Query, for currentUserId: Int) -> Query { - return isCurrentUserMailbox(mailbox, for: currentUserId) - && mailbox.isPasswordValid == false - && !isMailboxConsideredLocked(mailbox) - } - private static func filterLockedMailboxes(_ mailbox: Query, for currentUserId: Int) -> Query { - return isCurrentUserMailbox(mailbox, for: currentUserId) && isMailboxConsideredLocked(mailbox) + return isCurrentUserMailbox(mailbox, for: currentUserId) && mailbox.isLocked == true } private static func isCurrentUserMailbox(_ mailbox: Query, for currentUserId: Int) -> Query { return mailbox.userId == currentUserId } - - private static func isMailboxConsideredLocked(_ mailbox: Query) -> Query { - return mailbox.isLocked == true || mailbox.isValidInLDAP == false - } } #Preview { diff --git a/Mail/Views/Menu Drawer/MailboxManagement/MailboxCell.swift b/Mail/Views/Menu Drawer/MailboxManagement/MailboxCell.swift index 99d930e899..91dc3d43dd 100644 --- a/Mail/Views/Menu Drawer/MailboxManagement/MailboxCell.swift +++ b/Mail/Views/Menu Drawer/MailboxManagement/MailboxCell.swift @@ -46,7 +46,7 @@ struct MailboxCell: View { var isSelected = false enum Style { - case menuDrawer, account, blockedPassword, locked + case menuDrawer, account, locked } var body: some View { @@ -56,7 +56,7 @@ struct MailboxCell: View { isSelected: isSelected ) { guard !isSelected else { return } - guard !mailbox.isConsideredLocked && mailbox.isPasswordValid else { + guard !mailbox.isLocked else { isShowingLockedView = true return } @@ -65,8 +65,6 @@ struct MailboxCell: View { @InjectService var matomo: MatomoUtils switch style { - case .blockedPassword: - break case .locked: return case .menuDrawer: diff --git a/Mail/Views/Menu Drawer/MailboxManagement/MailboxesManagementButtonView.swift b/Mail/Views/Menu Drawer/MailboxManagement/MailboxesManagementButtonView.swift index 90eb5bb18c..3591c52e42 100644 --- a/Mail/Views/Menu Drawer/MailboxManagement/MailboxesManagementButtonView.swift +++ b/Mail/Views/Menu Drawer/MailboxManagement/MailboxesManagementButtonView.swift @@ -63,13 +63,11 @@ struct MailboxesManagementButtonView: View { .lineLimit(1) .frame(maxWidth: .infinity, alignment: .leading) - if !mailbox.isAvailable && style != .blockedPassword && style != .locked { + if mailbox.isLocked && style != .locked { MailResourcesAsset.warningFill.swiftUIImage .foregroundStyle(MailResourcesAsset.orangeColor.swiftUIColor) } else { switch style { - case .blockedPassword: - ChevronIcon(direction: .right, shapeStyle: MailResourcesAsset.textPrimaryColor.swiftUIColor) case .menuDrawer: if let detailNumber { Text(detailNumber, format: .indicatorCappedCount) diff --git a/Mail/Views/New Message/Select Mailbox/SelectComposeMailboxViewModel.swift b/Mail/Views/New Message/Select Mailbox/SelectComposeMailboxViewModel.swift index a8b62d59d5..dff934515d 100644 --- a/Mail/Views/New Message/Select Mailbox/SelectComposeMailboxViewModel.swift +++ b/Mail/Views/New Message/Select Mailbox/SelectComposeMailboxViewModel.swift @@ -82,7 +82,7 @@ final class SelectComposeMailboxViewModel: ObservableObject { } func selectMailbox(_ mailbox: Mailbox) { - guard mailbox.isAvailable, + guard !mailbox.isLocked, let user = userProfiles.first(where: { $0.id == mailbox.userId }), let mailboxManager = accountManager.getMailboxManager(for: mailbox.mailboxId, userId: mailbox.userId) else { snackbarPresenter.show(message: MailResourcesStrings.Localizable.errorMailboxUnavailable) diff --git a/MailCore/Cache/AccountManager/AccountManager.swift b/MailCore/Cache/AccountManager/AccountManager.swift index 93022cc344..aa57cc7eb5 100644 --- a/MailCore/Cache/AccountManager/AccountManager.swift +++ b/MailCore/Cache/AccountManager/AccountManager.swift @@ -72,7 +72,7 @@ public final class AccountManager: RefreshTokenDelegate, ObservableObject { return currentMailboxManager } else if let newCurrentMailbox = mailboxInfosManager.getMailboxes(for: currentUserId) .sorted(by: { lhs, _ in lhs.isPrimary }) - .first(where: \.isAvailable) { + .first(where: { !$0.isLocked }) { setCurrentMailboxForCurrentAccount(mailbox: newCurrentMailbox) return getMailboxManager(for: newCurrentMailbox) } else { @@ -231,7 +231,7 @@ public final class AccountManager: RefreshTokenDelegate, ObservableObject { } public func setCurrentAccount(token: ApiToken, mailboxes: [Mailbox], apiFetcher: ApiFetcher) async { - let availableMailboxes = mailboxes.filter { $0.isAvailable } + let availableMailboxes = mailboxes.filter { !$0.isLocked } guard let mainMailbox = (availableMailboxes.first(where: { $0.isPrimary }) ?? availableMailboxes.first)?.freezeIfNeeded() else { return @@ -284,7 +284,7 @@ public final class AccountManager: RefreshTokenDelegate, ObservableObject { MailboxManager.deleteUserMailbox(userId: user.id, mailboxId: mailboxRemoved.mailboxId) } - if currentMailboxManager?.mailbox.isAvailable == false { + if currentMailboxManager?.mailbox.isLocked == true { switchToFirstValidMailboxManager() } @@ -318,7 +318,7 @@ public final class AccountManager: RefreshTokenDelegate, ObservableObject { private func fetchMailboxesMetadata(mailboxes: [Mailbox], apiFetcher: MailApiFetcher) async { await withTaskGroup(of: Void.self) { group in - for mailbox in mailboxes where mailbox.isAvailable { + for mailbox in mailboxes where !mailbox.isLocked { group.addTask { async let permissions = apiFetcher.permissions(mailbox: mailbox) async let externalMailInfo = apiFetcher.externalMailFlag(mailbox: mailbox) @@ -342,13 +342,13 @@ public final class AccountManager: RefreshTokenDelegate, ObservableObject { public func switchToFirstValidMailboxManager() { // Current mailbox is valid - if let firstValidMailboxManager = currentMailboxManager, firstValidMailboxManager.mailbox.isAvailable { + if let firstValidMailboxManager = currentMailboxManager, !firstValidMailboxManager.mailbox.isLocked { return } // At least one mailbox is valid let mailboxes = mailboxInfosManager.getMailboxes(for: currentUserId) - if let firstValidMailbox = mailboxes.first(where: { $0.isAvailable && $0.userId == currentUserId }) { + if let firstValidMailbox = mailboxes.first(where: { !$0.isLocked && $0.userId == currentUserId }) { switchMailbox(newMailbox: firstValidMailbox) return } diff --git a/MailCore/Cache/MailboxInfosManager/MailboxInfosManager.swift b/MailCore/Cache/MailboxInfosManager/MailboxInfosManager.swift index 13f1f5e968..b754d738e9 100644 --- a/MailCore/Cache/MailboxInfosManager/MailboxInfosManager.swift +++ b/MailCore/Cache/MailboxInfosManager/MailboxInfosManager.swift @@ -26,7 +26,7 @@ import RealmSwift extension MailboxInfosManager: RealmConfigurable {} public final class MailboxInfosManager { - private static let currentDbVersion: UInt64 = 15 + private static let currentDbVersion: UInt64 = 16 private let dbName = "MailboxInfos.realm" public let realmConfiguration: Realm.Configuration diff --git a/MailCore/Cache/RootViewState.swift b/MailCore/Cache/RootViewState.swift index 3d2c2e6f35..fcb608cfbd 100644 --- a/MailCore/Cache/RootViewState.swift +++ b/MailCore/Cache/RootViewState.swift @@ -123,7 +123,7 @@ public class RootViewState: ObservableObject { } else { let mailboxes = mailboxInfosManager.getMailboxes(for: currentAccount.userId) - if !mailboxes.isEmpty && mailboxes.allSatisfy({ !$0.isAvailable }) { + if !mailboxes.isEmpty && mailboxes.allSatisfy({ $0.isLocked }) { transitionToRootViewState(.unavailableMailboxes(currentAccount)) } else { transitionToRootViewState(.preloading) diff --git a/MailCore/Models/Mailbox.swift b/MailCore/Models/Mailbox.swift index 7a0a65fe1d..14a1d43974 100644 --- a/MailCore/Models/Mailbox.swift +++ b/MailCore/Models/Mailbox.swift @@ -62,8 +62,6 @@ public class Mailbox: Object, Codable, Identifiable { @Persisted public var mailboxId: Int @Persisted public var hostingId: Int @Persisted public var isPrimary: Bool - @Persisted public var isPasswordValid: Bool - @Persisted public var isValidInLDAP: Bool @Persisted public var isLocked: Bool @Persisted public var isSpamFilter: Bool @Persisted public var isLimited: Bool @@ -92,14 +90,6 @@ public class Mailbox: Object, Codable, Identifiable { return uuid } - public var isConsideredLocked: Bool { - return isLocked || !isValidInLDAP - } - - public var isAvailable: Bool { - return isPasswordValid && !isConsideredLocked - } - public var notificationTopicName: Topic { return Topic(rawValue: "mailbox-\(mailboxId)") } @@ -117,8 +107,6 @@ public class Mailbox: Object, Codable, Identifiable { case mailboxId case hostingId case isPrimary - case isPasswordValid - case isValidInLDAP = "isValid" case isLocked case isSpamFilter case isLimited @@ -146,8 +134,6 @@ public class Mailbox: Object, Codable, Identifiable { mailboxId: Int, hostingId: Int, isPrimary: Bool, - isPasswordValid: Bool, - isValidInLDAP: Bool, isLocked: Bool, isSpamFilter: Bool, isLimited: Bool, @@ -165,8 +151,6 @@ public class Mailbox: Object, Codable, Identifiable { self.mailboxId = mailboxId self.hostingId = hostingId self.isPrimary = isPrimary - self.isPasswordValid = isPasswordValid - self.isValidInLDAP = isValidInLDAP self.isLocked = isLocked self.isSpamFilter = isSpamFilter self.isLimited = isLimited @@ -185,8 +169,6 @@ public class Mailbox: Object, Codable, Identifiable { mailboxId = try container.decode(Int.self, forKey: .mailboxId) hostingId = try container.decode(Int.self, forKey: .hostingId) isPrimary = try container.decode(Bool.self, forKey: .isPrimary) - isPasswordValid = try container.decode(Bool.self, forKey: .isPasswordValid) - isValidInLDAP = try container.decode(Bool.self, forKey: .isValidInLDAP) isLocked = try container.decode(Bool.self, forKey: .isLocked) isSpamFilter = try container.decode(Bool.self, forKey: .isSpamFilter) isLimited = try container.decodeIfPresent(Bool.self, forKey: .isLimited) ?? false diff --git a/MailCoreUI/Helpers/PreviewHelper.swift b/MailCoreUI/Helpers/PreviewHelper.swift index 4f370434db..024e6ffae0 100644 --- a/MailCoreUI/Helpers/PreviewHelper.swift +++ b/MailCoreUI/Helpers/PreviewHelper.swift @@ -65,8 +65,6 @@ public enum PreviewHelper { mailboxId: 0, hostingId: 0, isPrimary: true, - isPasswordValid: true, - isValidInLDAP: true, isLocked: false, isSpamFilter: false, isLimited: false, diff --git a/MailResources/Localizable/de.lproj/Localizable.stringsdict b/MailResources/Localizable/de.lproj/Localizable.stringsdict index 84aad88993..b043da1522 100644 --- a/MailResources/Localizable/de.lproj/Localizable.stringsdict +++ b/MailResources/Localizable/de.lproj/Localizable.stringsdict @@ -5,8 +5,8 @@ Project: kMail Locale: de, German Tagged: ios-stringsdict - Exported by: Valentin Perignon - Exported at: Tue, 04 Nov 2025 14:17:22 +0100 + Exported by: Ambroise Decouttere + Exported at: Tue, 16 Dec 2025 15:09:51 +0100 --> @@ -26,22 +26,6 @@ %d Anhänge - blockedPasswordTitle - - NSStringLocalizedFormatKey - %#@value@ - value - - NSStringFormatSpecTypeKey - NSStringPluralRuleType - NSStringFormatValueTypeKey - d - one - Passwort blockiert - other - Blockierte Passwörter - - encryptedMessageIncompleteUser NSStringLocalizedFormatKey diff --git a/MailResources/Localizable/en.lproj/Localizable.stringsdict b/MailResources/Localizable/en.lproj/Localizable.stringsdict index b5d66d545d..d827689791 100644 --- a/MailResources/Localizable/en.lproj/Localizable.stringsdict +++ b/MailResources/Localizable/en.lproj/Localizable.stringsdict @@ -5,8 +5,8 @@ Project: kMail Locale: en, English Tagged: ios-stringsdict - Exported by: Valentin Perignon - Exported at: Tue, 04 Nov 2025 14:17:22 +0100 + Exported by: Ambroise Decouttere + Exported at: Tue, 16 Dec 2025 15:09:51 +0100 --> @@ -26,22 +26,6 @@ %d attachments - blockedPasswordTitle - - NSStringLocalizedFormatKey - %#@value@ - value - - NSStringFormatSpecTypeKey - NSStringPluralRuleType - NSStringFormatValueTypeKey - d - one - Blocked password - other - Blocked passwords - - encryptedMessageIncompleteUser NSStringLocalizedFormatKey diff --git a/MailResources/Localizable/es.lproj/Localizable.stringsdict b/MailResources/Localizable/es.lproj/Localizable.stringsdict index e6cc7cf29f..f34d6c13b7 100644 --- a/MailResources/Localizable/es.lproj/Localizable.stringsdict +++ b/MailResources/Localizable/es.lproj/Localizable.stringsdict @@ -5,8 +5,8 @@ Project: kMail Locale: es, Spanish Tagged: ios-stringsdict - Exported by: Valentin Perignon - Exported at: Tue, 04 Nov 2025 14:17:22 +0100 + Exported by: Ambroise Decouttere + Exported at: Tue, 16 Dec 2025 15:09:51 +0100 --> @@ -26,22 +26,6 @@ %d archivos adjuntos - blockedPasswordTitle - - NSStringLocalizedFormatKey - %#@value@ - value - - NSStringFormatSpecTypeKey - NSStringPluralRuleType - NSStringFormatValueTypeKey - d - one - Contraseña bloqueada - other - Contraseñas bloqueadas - - encryptedMessageIncompleteUser NSStringLocalizedFormatKey diff --git a/MailResources/Localizable/fr.lproj/Localizable.stringsdict b/MailResources/Localizable/fr.lproj/Localizable.stringsdict index f1eaa1e98a..242a0909bc 100644 --- a/MailResources/Localizable/fr.lproj/Localizable.stringsdict +++ b/MailResources/Localizable/fr.lproj/Localizable.stringsdict @@ -5,8 +5,8 @@ Project: kMail Locale: fr, French Tagged: ios-stringsdict - Exported by: Valentin Perignon - Exported at: Tue, 04 Nov 2025 14:17:22 +0100 + Exported by: Ambroise Decouttere + Exported at: Tue, 16 Dec 2025 15:09:51 +0100 --> @@ -28,24 +28,6 @@ %d de pièces jointes - blockedPasswordTitle - - NSStringLocalizedFormatKey - %#@value@ - value - - NSStringFormatSpecTypeKey - NSStringPluralRuleType - NSStringFormatValueTypeKey - d - one - Mot de passe bloqué - other - Mots de passe bloqués - many - Mots de passe bloqués - - encryptedMessageIncompleteUser NSStringLocalizedFormatKey diff --git a/MailResources/Localizable/it.lproj/Localizable.stringsdict b/MailResources/Localizable/it.lproj/Localizable.stringsdict index 4b8b198f77..2991bd40ae 100644 --- a/MailResources/Localizable/it.lproj/Localizable.stringsdict +++ b/MailResources/Localizable/it.lproj/Localizable.stringsdict @@ -5,8 +5,8 @@ Project: kMail Locale: it, Italian Tagged: ios-stringsdict - Exported by: Valentin Perignon - Exported at: Tue, 04 Nov 2025 14:17:22 +0100 + Exported by: Ambroise Decouttere + Exported at: Tue, 16 Dec 2025 15:09:51 +0100 --> @@ -26,22 +26,6 @@ %d allegati - blockedPasswordTitle - - NSStringLocalizedFormatKey - %#@value@ - value - - NSStringFormatSpecTypeKey - NSStringPluralRuleType - NSStringFormatValueTypeKey - d - one - Password bloccata - other - Password bloccate - - encryptedMessageIncompleteUser NSStringLocalizedFormatKey