Skip to content
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
32 changes: 1 addition & 31 deletions Mail/Components/UnavailableMailboxListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,9 @@ import RealmSwift
import SwiftUI

struct UnavailableMailboxListView: View {
@ObservedResults var passwordBlockedMailboxes: Results<Mailbox>
@ObservedResults var lockedMailboxes: Results<Mailbox>

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: {
Expand All @@ -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))
Expand All @@ -76,23 +56,13 @@ struct UnavailableMailboxListView: View {
.padding(.top, IKPadding.large)
}

private static func filterPasswordBlockedMailboxes(_ mailbox: Query<Mailbox>, for currentUserId: Int) -> Query<Bool> {
return isCurrentUserMailbox(mailbox, for: currentUserId)
&& mailbox.isPasswordValid == false
&& !isMailboxConsideredLocked(mailbox)
}

private static func filterLockedMailboxes(_ mailbox: Query<Mailbox>, for currentUserId: Int) -> Query<Bool> {
return isCurrentUserMailbox(mailbox, for: currentUserId) && isMailboxConsideredLocked(mailbox)
return isCurrentUserMailbox(mailbox, for: currentUserId) && mailbox.isLocked == true
}

private static func isCurrentUserMailbox(_ mailbox: Query<Mailbox>, for currentUserId: Int) -> Query<Bool> {
return mailbox.userId == currentUserId
}

private static func isMailboxConsideredLocked(_ mailbox: Query<Mailbox>) -> Query<Bool> {
return mailbox.isLocked == true || mailbox.isValidInLDAP == false
}
}

#Preview {
Expand Down
6 changes: 2 additions & 4 deletions Mail/Views/Menu Drawer/MailboxManagement/MailboxCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand All @@ -65,8 +65,6 @@ struct MailboxCell: View {
@InjectService var matomo: MatomoUtils

switch style {
case .blockedPassword:
break
case .locked:
return
case .menuDrawer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions MailCore/Cache/AccountManager/AccountManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import Sentry
import SwiftUI

extension InfomaniakCore.UserProfile: Identifiable {}

Check warning on line 34 in MailCore/Cache/AccountManager/AccountManager.swift

View workflow job for this annotation

GitHub Actions / Build and Test project

extension declares a conformance of imported type 'UserProfile' to imported protocol 'Identifiable'; this will not behave correctly if the owners of 'InfomaniakCore' introduce this conformance in the future

Check warning on line 34 in MailCore/Cache/AccountManager/AccountManager.swift

View workflow job for this annotation

GitHub Actions / UI Tests

extension declares a conformance of imported type 'UserProfile' to imported protocol 'Identifiable'; this will not behave correctly if the owners of 'InfomaniakCore' introduce this conformance in the future

Check warning on line 34 in MailCore/Cache/AccountManager/AccountManager.swift

View workflow job for this annotation

GitHub Actions / UI Tests

extension declares a conformance of imported type 'UserProfile' to imported protocol 'Identifiable'; this will not behave correctly if the owners of 'InfomaniakCore' introduce this conformance in the future

public final class AccountManager: RefreshTokenDelegate, ObservableObject {
@LazyInjectService var deviceManager: DeviceManagerable
Expand Down Expand Up @@ -72,7 +72,7 @@
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 {
Expand Down Expand Up @@ -231,7 +231,7 @@
}

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
Expand Down Expand Up @@ -284,7 +284,7 @@
MailboxManager.deleteUserMailbox(userId: user.id, mailboxId: mailboxRemoved.mailboxId)
}

if currentMailboxManager?.mailbox.isAvailable == false {
if currentMailboxManager?.mailbox.isLocked == true {
switchToFirstValidMailboxManager()
}

Expand Down Expand Up @@ -318,7 +318,7 @@

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)
Expand All @@ -342,13 +342,13 @@

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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion MailCore/Cache/RootViewState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 0 additions & 18 deletions MailCore/Models/Mailbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)")
}
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions MailCoreUI/Helpers/PreviewHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public enum PreviewHelper {
mailboxId: 0,
hostingId: 0,
isPrimary: true,
isPasswordValid: true,
isValidInLDAP: true,
isLocked: false,
isSpamFilter: false,
isLimited: false,
Expand Down
20 changes: 2 additions & 18 deletions MailResources/Localizable/de.lproj/Localizable.stringsdict
Original file line number Diff line number Diff line change
Expand Up @@ -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
-->
<plist version="1.0">
<dict>
Expand All @@ -26,22 +26,6 @@
<string>%d Anhänge</string>
</dict>
</dict>
<key>blockedPasswordTitle</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@value@</string>
<key>value</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>Passwort blockiert</string>
<key>other</key>
<string>Blockierte Passwörter</string>
</dict>
</dict>
<key>encryptedMessageIncompleteUser</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
Expand Down
20 changes: 2 additions & 18 deletions MailResources/Localizable/en.lproj/Localizable.stringsdict
Original file line number Diff line number Diff line change
Expand Up @@ -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
-->
<plist version="1.0">
<dict>
Expand All @@ -26,22 +26,6 @@
<string>%d attachments</string>
</dict>
</dict>
<key>blockedPasswordTitle</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@value@</string>
<key>value</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>Blocked password</string>
<key>other</key>
<string>Blocked passwords</string>
</dict>
</dict>
<key>encryptedMessageIncompleteUser</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
Expand Down
20 changes: 2 additions & 18 deletions MailResources/Localizable/es.lproj/Localizable.stringsdict
Original file line number Diff line number Diff line change
Expand Up @@ -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
-->
<plist version="1.0">
<dict>
Expand All @@ -26,22 +26,6 @@
<string>%d archivos adjuntos</string>
</dict>
</dict>
<key>blockedPasswordTitle</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@value@</string>
<key>value</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>Contraseña bloqueada</string>
<key>other</key>
<string>Contraseñas bloqueadas</string>
</dict>
</dict>
<key>encryptedMessageIncompleteUser</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
Expand Down
22 changes: 2 additions & 20 deletions MailResources/Localizable/fr.lproj/Localizable.stringsdict
Original file line number Diff line number Diff line change
Expand Up @@ -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
-->
<plist version="1.0">
<dict>
Expand All @@ -28,24 +28,6 @@
<string>%d de pièces jointes</string>
</dict>
</dict>
<key>blockedPasswordTitle</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@value@</string>
<key>value</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>Mot de passe bloqué</string>
<key>other</key>
<string>Mots de passe bloqués</string>
<key>many</key>
<string>Mots de passe bloqués</string>
</dict>
</dict>
<key>encryptedMessageIncompleteUser</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
Expand Down
Loading
Loading