Skip to content

Commit

Permalink
refactor: Remove unused code (#1409)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeWeidmann committed May 2, 2024
2 parents 330e7be + d6570f7 commit c11711c
Show file tree
Hide file tree
Showing 72 changed files with 27 additions and 256 deletions.
2 changes: 0 additions & 2 deletions Mail/Components/ActionsPanelButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import CocoaLumberjackSwift
import MailCore
import MailResources
import SwiftUI

struct ActionsPanelButton<Content: View>: View {
Expand Down
1 change: 0 additions & 1 deletion Mail/Components/Custom Buttons/AccountButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import InfomaniakCore
import MailCore
import MailCoreUI
import MailResources
import SwiftModalPresentation
import SwiftUI

Expand Down
4 changes: 0 additions & 4 deletions Mail/Components/ThreadCell/ThreadCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ struct ThreadCell: View {
let isSelected: Bool
let avatarTapped: (() -> Void)?

private var checkboxSize: CGFloat {
density == .large ? UIConstants.checkboxLargeSize : UIConstants.checkboxSize
}

private var additionalAccessibilityLabel: String {
var label = ""
if isSelected {
Expand Down
1 change: 0 additions & 1 deletion Mail/DisplayThreadScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

import MailCore
import MailResources
import SwiftUI

struct DisplayThreadScene: Scene {
Expand Down
2 changes: 0 additions & 2 deletions Mail/Helpers/Notifications/NotificationCenterDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@ final class NotificationCenterDelegate: NSObject, UNUserNotificationCenterDelega
case NewMailActionIdentifier.archive:
try? await messageActions.handleArchiveOnNotification(
messageUid: messageUid,
mailbox: mailbox,
mailboxManager: mailboxManager
)
case NewMailActionIdentifier.delete:
try? await messageActions.handleDeleteOnNotification(
messageUid: messageUid,
mailbox: mailbox,
mailboxManager: mailboxManager
)
case NewMailActionIdentifier.reply:
Expand Down
14 changes: 0 additions & 14 deletions Mail/Helpers/RichTextEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,6 @@ struct RichTextEditor: UIViewRepresentable {
}
}

extension SQTextEditorView {
func insertHtml(_ html: String) async throws {
return try await withCheckedThrowingContinuation { continuation in
insertHTML(html) { error in
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume()
}
}
}
}
}

struct RichTextEditorModel {
var cursorPosition: CGFloat = 0
var height: CGFloat = 0
Expand Down
7 changes: 0 additions & 7 deletions Mail/MailApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@
*/

import CocoaLumberjackSwift
import Contacts
import InfomaniakBugTracker
import InfomaniakCore
import InfomaniakCoreUI
import InfomaniakDI
import InfomaniakLogin
import InfomaniakNotifications
import MailCore
import MailResources
import SwiftUI
import UIKit

Expand Down
4 changes: 2 additions & 2 deletions Mail/Proxy/Implementation/MessageActionHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public struct MessageActionHandler: MessageActionHandlable {
messageId: messageUid))
}

func handleArchiveOnNotification(messageUid: String, mailbox: Mailbox, mailboxManager: MailboxManager) async throws {
func handleArchiveOnNotification(messageUid: String, mailboxManager: MailboxManager) async throws {
let backgroundTaskTracker = await ApplicationBackgroundTaskTracker(identifier: #function + UUID().uuidString)

matomo.track(eventWithCategory: .notificationActions, name: ActionNames.archive)
Expand All @@ -80,7 +80,7 @@ public struct MessageActionHandler: MessageActionHandlable {
await backgroundTaskTracker.end()
}

func handleDeleteOnNotification(messageUid: String, mailbox: Mailbox, mailboxManager: MailboxManager) async throws {
func handleDeleteOnNotification(messageUid: String, mailboxManager: MailboxManager) async throws {
let backgroundTaskTracker = await ApplicationBackgroundTaskTracker(identifier: #function + UUID().uuidString)

matomo.track(eventWithCategory: .notificationActions, name: ActionNames.delete)
Expand Down
4 changes: 2 additions & 2 deletions Mail/Proxy/Protocols/MessageActionHandlable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ protocol MessageActionHandlable {
func handleTapOnNotification(messageUid: String, mailbox: Mailbox, mailboxManager: MailboxManager) async throws

/// Silently move mail to `archive` folder
func handleArchiveOnNotification(messageUid: String, mailbox: Mailbox, mailboxManager: MailboxManager) async throws
func handleArchiveOnNotification(messageUid: String, mailboxManager: MailboxManager) async throws

/// Silently move mail to `trash` folder
func handleDeleteOnNotification(messageUid: String, mailbox: Mailbox, mailboxManager: MailboxManager) async throws
func handleDeleteOnNotification(messageUid: String, mailboxManager: MailboxManager) async throws

/// Present a new `reply to` draft to the user with the correct account
func handleReplyOnNotification(messageUid: String, mailbox: Mailbox, mailboxManager: MailboxManager)
Expand Down
1 change: 0 additions & 1 deletion Mail/UserAccountScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct UserAccountScene: Scene {
@Environment(\.scenePhase) private var scenePhase

@LazyInjectService private var appLockHelper: AppLockHelper
@LazyInjectService private var accountManager: AccountManager
@LazyInjectService private var appLaunchCounter: AppLaunchCounter
@LazyInjectService private var refreshAppBackgroundTask: RefreshAppBackgroundTask
@LazyInjectService private var reviewManager: ReviewManageable
Expand Down
24 changes: 0 additions & 24 deletions Mail/Utils/DateInterval+Extension.swift

This file was deleted.

16 changes: 0 additions & 16 deletions Mail/Views/AI Writer/AIModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,20 +320,4 @@ enum AIError: LocalizedError {
return MailResourcesStrings.Localizable.aiErrorUnknown
}
}

init(from error: Error) {
guard let mailApiError = error as? MailApiError else {
self = .unknownError
return
}

switch mailApiError {
case .apiAITooManyRequests:
self = .tooManyRequests
case .apiAIMaxSyntaxTokensReached:
self = .maxSyntaxTokensReached
default:
self = .unknownError
}
}
}
1 change: 0 additions & 1 deletion Mail/Views/Attachment/AttachmentPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import SwiftUI

struct AttachmentPreview: View {
@LazyInjectService private var matomo: MatomoUtils
@LazyInjectService private var urlOpener: URLOpenable

@Environment(\.dismiss) private var dismiss
@Environment(\.verticalSizeClass) private var sizeClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import InfomaniakCoreUI
import InfomaniakDI
import MailCore
import MailCoreUI
import MailResources
import SwiftUI

struct ContactActionsView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import InfomaniakCoreUI
import MailCore
import MailCoreUI
import MailResources
import NavigationBackport
import RealmSwift
import SwiftUI
Expand Down
1 change: 0 additions & 1 deletion Mail/Views/Menu Drawer/FolderListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import InfomaniakDI
import MailCore
import MailCoreUI
import MailResources
import RealmSwift
import SwiftUI

Expand Down
1 change: 0 additions & 1 deletion Mail/Views/Menu Drawer/Folders/FoldersListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import InfomaniakCore
import InfomaniakCoreUI
import MailCore
import MailResources
import RealmSwift
import SwiftUI

Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Menu Drawer/MailboxManagement/MailboxCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct MailboxCell: View {
navigationDrawerState.close()
}
.floatingPanel(isPresented: $isShowingLockedView) {
LockedMailboxView(lockedMailbox: mailbox)
LockedMailboxView()
}
.sheet(isPresented: $isShowingUpdatePasswordView) {
UpdateMailboxPasswordView(mailbox: mailbox)
Expand Down
2 changes: 0 additions & 2 deletions Mail/Views/Menu Drawer/MenuDrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ struct NavigationDrawer: View {
struct MenuDrawerView: View {
@EnvironmentObject private var mailboxManager: MailboxManager

@State private var isShowingRestoreMails = false

var body: some View {
VStack(spacing: 0) {
MenuHeaderView()
Expand Down
23 changes: 1 addition & 22 deletions Mail/Views/New Message/Attachments/AttachmentsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import SwiftUI

/// Something to deal with the tracking and Upload of Attachments linked to a Draft.
@MainActor protocol AttachmentsManageable {
/// The `live` Draft
var liveDraft: Draft? { get }

/// Live Attachments linked to the Draft
var liveAttachments: [Attachment] { get }

Expand Down Expand Up @@ -64,22 +61,13 @@ import SwiftUI

/// Something to track `Attachments` linked to a live `Draft`
@MainActor final class AttachmentsManager: ObservableObject, AttachmentsManageable {
private let draftLocalUUID: String

/// Async attachment operations
private let worker: AttachmentsManagerWorker

private let mailboxManager: MailboxManager
private let backgroundRealm: BackgroundRealm

/// Something to debounce content will change updates
private let contentWillChangeSubject = PassthroughSubject<Void, Never>()
private var contentWillChangeObserver: AnyCancellable?

var liveDraft: Draft? {
worker.liveDraft
}

var liveAttachments: [Attachment] {
worker.liveAttachments
}
Expand All @@ -91,17 +79,8 @@ import SwiftUI
var globalError: MailError?

init(draftLocalUUID: String, mailboxManager: MailboxManager) {
self.draftLocalUUID = draftLocalUUID
self.mailboxManager = mailboxManager
let realm = BackgroundRealm(configuration: mailboxManager.realmConfiguration)
backgroundRealm = realm

// Debouncing objectWillChange helps a lot scaling with numerous attachments
worker = AttachmentsManagerWorker(
backgroundRealm: realm,
draftLocalUUID: draftLocalUUID,
mailboxManager: mailboxManager
)
worker = AttachmentsManagerWorker(draftLocalUUID: draftLocalUUID, mailboxManager: mailboxManager)

contentWillChangeObserver = contentWillChangeSubject
.debounce(for: .milliseconds(150), scheduler: DispatchQueue.main)
Expand Down
1 change: 0 additions & 1 deletion Mail/Views/New Message/AutocompletionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import Combine
import MailCore
import MailCoreUI
import MailResources
import RealmSwift
import SwiftUI

Expand Down
2 changes: 0 additions & 2 deletions Mail/Views/New Message/ComposeMessageBodyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct ComposeMessageBodyView: View {

@Binding var editorModel: RichTextEditorModel
@Binding var editorFocus: Bool
@Binding var currentSignature: Signature?
@Binding var isShowingAIPrompt: Bool
@Binding var isShowingAlert: NewMessageAlert?

Expand Down Expand Up @@ -101,7 +100,6 @@ struct ComposeMessageBodyView: View {
return ComposeMessageBodyView(draft: draft,
editorModel: .constant(RichTextEditorModel()),
editorFocus: .constant(false),
currentSignature: .constant(nil),
isShowingAIPrompt: .constant(false),
isShowingAlert: .constant(nil),
attachmentsManager: AttachmentsManager(
Expand Down
3 changes: 1 addition & 2 deletions Mail/Views/New Message/ComposeMessageHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ struct ComposeMessageHeaderView: View {
currentSignature: $currentSignature,
mailboxManager: mailboxManager,
autocompletionType: autocompletionType,
type: .from,
text: mailboxManager.mailbox.email
type: .from
)

ComposeMessageCellRecipients(
Expand Down
1 change: 0 additions & 1 deletion Mail/Views/New Message/ComposeMessageIntentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import InfomaniakCoreDB
import InfomaniakDI
import MailCore
import MailCoreUI
import MailResources
import NavigationBackport
import RealmSwift
import SwiftUI
Expand Down
1 change: 0 additions & 1 deletion Mail/Views/New Message/ComposeMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ struct ComposeMessageView: View {
draft: draft,
editorModel: $editorModel,
editorFocus: $editorFocus,
currentSignature: $currentSignature,
isShowingAIPrompt: $aiModel.isShowingPrompt,
isShowingAlert: $isShowingAlert,
attachmentsManager: attachmentsManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
import InfomaniakDI
import MailCore
import MailCoreUI
import MailResources
import RealmSwift
import SwiftUI

struct ComposeMessageSenderMenu: View {
@EnvironmentObject private var draftContentManager: DraftContentManager
@EnvironmentObject private var mailboxManager: MailboxManager

@ObservedResults(Signature.self) private var signatures
Expand All @@ -33,7 +31,6 @@ struct ComposeMessageSenderMenu: View {

let autocompletionType: ComposeViewFieldType?
let type: ComposeViewFieldType
let text: String

private var canSelectSignature: Bool {
!signatures.isEmpty
Expand All @@ -47,14 +44,12 @@ struct ComposeMessageSenderMenu: View {
currentSignature: Binding<Signature?>,
mailboxManager: MailboxManager,
autocompletionType: ComposeViewFieldType?,
type: ComposeViewFieldType,
text: String
type: ComposeViewFieldType
) {
_currentSignature = currentSignature
_signatures = ObservedResults(Signature.self, configuration: mailboxManager.realmConfiguration)
self.autocompletionType = autocompletionType
self.type = type
self.text = text
}

var body: some View {
Expand Down Expand Up @@ -95,7 +90,6 @@ struct ComposeMessageSenderMenu: View {
currentSignature: .constant(nil),
mailboxManager: PreviewHelper.sampleMailboxManager,
autocompletionType: nil,
type: .from,
text: "email@email.com"
type: .from
)
}
1 change: 0 additions & 1 deletion Mail/Views/New Message/Header Cells/SenderMenuCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import SwiftUI

struct SenderMenuCell: View {
@LazyInjectService private var matomo: MatomoUtils
@LazyInjectService private var platformDetector: PlatformDetectable

@EnvironmentObject private var draftContentManager: DraftContentManager
@EnvironmentObject private var mailboxManager: MailboxManager
Expand Down
Loading

0 comments on commit c11711c

Please sign in to comment.