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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ struct ActionsPanelViewModifier: ViewModifier {

@EnvironmentObject private var mailboxManager: MailboxManager

@ModalState private var reportForJunkMessages: [Message]?
@ModalState private var reportedForDisplayProblemMessage: Message?
@ModalState private var reportedForPhishingMessages: [Message]?
@ModalState private var blockSenderAlert: BlockRecipientAlertState?
Expand All @@ -73,7 +72,6 @@ struct ActionsPanelViewModifier: ViewModifier {
nearestMessagesToMoveSheet: $messagesToMove,
nearestBlockSenderAlert: $blockSenderAlert,
nearestBlockSendersList: $blockSendersList,
nearestReportJunkMessagesActionsPanel: $reportForJunkMessages,
nearestReportedForPhishingMessagesAlert: $reportedForPhishingMessages,
nearestReportedForDisplayProblemMessageAlert: $reportedForDisplayProblemMessage,
nearestShareMailLinkPanel: $shareMailLink,
Expand All @@ -92,7 +90,7 @@ struct ActionsPanelViewModifier: ViewModifier {
}

func body(content: Content) -> some View {
content.adaptivePanel(item: $messages, popoverArrowEdge: popoverArrowEdge) { messages in
content.adaptivePanel(item: $messages, style: .native, popoverArrowEdge: popoverArrowEdge) { messages in
ActionsView(
user: currentUser.value,
target: messages,
Expand All @@ -110,10 +108,6 @@ struct ActionsPanelViewModifier: ViewModifier {
)
.sheetViewStyle()
}
.mailFloatingPanel(item: $reportForJunkMessages) { reportForJunkMessages in
ReportJunkView(reportedMessages: reportForJunkMessages, origin: origin, completionHandler: completionHandler)
.environmentObject(mailboxManager) // Force environment object to prevent crash on macOS
}
.mailFloatingPanel(item: $blockSendersList,
title: MailResourcesStrings.Localizable.blockAnExpeditorTitle) { blockSenderState in
BlockSenderView(recipientsToMessage: blockSenderState.recipientsToMessage, origin: origin)
Expand Down
71 changes: 0 additions & 71 deletions Mail/Views/Bottom sheets/Actions/ReportJunkView.swift

This file was deleted.

5 changes: 0 additions & 5 deletions Mail/Views/Thread List/ThreadListCellContextMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ struct ThreadListCellContextMenu: ViewModifier {
@EnvironmentObject private var actionsManager: ActionsManager
@EnvironmentObject private var mailboxManager: MailboxManager

@ModalState private var reportForJunkMessages: [Message]?
@ModalState private var reportedForDisplayProblemMessage: Message?
@ModalState private var reportedForPhishingMessages: [Message]?
@ModalState private var blockSenderAlert: BlockRecipientAlertState?
Expand All @@ -64,7 +63,6 @@ struct ThreadListCellContextMenu: ViewModifier {
nearestMessagesToMoveSheet: $messagesToMove,
nearestBlockSenderAlert: $blockSenderAlert,
nearestBlockSendersList: $blockSendersList,
nearestReportJunkMessagesActionsPanel: $reportForJunkMessages,
nearestReportedForPhishingMessagesAlert: $reportedForPhishingMessages,
nearestReportedForDisplayProblemMessageAlert: $reportedForDisplayProblemMessage,
nearestShareMailLinkPanel: $shareMailLink,
Expand Down Expand Up @@ -126,9 +124,6 @@ struct ThreadListCellContextMenu: ViewModifier {
)
.sheetViewStyle()
}
.mailFloatingPanel(item: $reportForJunkMessages) { reportForJunkMessages in
ReportJunkView(reportedMessages: reportForJunkMessages, origin: origin)
}
.mailFloatingPanel(item: $blockSendersList,
title: MailResourcesStrings.Localizable.blockAnExpeditorTitle) { blockSenderState in
BlockSenderView(recipientsToMessage: blockSenderState.recipientsToMessage, origin: origin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct MessageHeaderSummaryView: View {
size: 40
)
}
.adaptivePanel(item: $contactViewRecipient) { recipient in
.adaptivePanel(item: $contactViewRecipient, style: .native) { recipient in
ContactActionsView(recipient: recipient, bimi: message.bimi)
.environmentObject(mailboxManager)
.environment(\.currentUser, currentUser)
Expand Down
44 changes: 25 additions & 19 deletions MailCore/Cache/Actions/Action+List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ extension Action: CaseIterable {
.star,
.star,
.unstar,
.reportJunk,
.spam,
.nonSpam,
.block,
Expand Down Expand Up @@ -77,7 +76,6 @@ extension Action: CaseIterable {
.openMovePanel,
.saveThreadInkDrive,
.shareMailLink,
.reportJunk,
.phishing,
.block,
.blockList,
Expand Down Expand Up @@ -111,22 +109,26 @@ extension Action: CaseIterable {

let snoozedActions = snoozedActions([message], folder: origin.frozenFolder)

let isFromMe = message.fromMe(currentMailboxEmail: userEmail)
let isInSpamFolder = message.folder?.role == .spam
var spamAction: Action? {
guard !message.fromMe(currentMailboxEmail: userEmail) else { return nil }
return message.folder?.role == .spam ? .nonSpam : .reportJunk
guard !isFromMe else { return nil }
return isInSpamFolder ? .nonSpam : .spam
}
let archive = message.folder?.role != .archive
let unread = !message.seen
let star = message.flagged
let print = origin.type == .floatingPanel(source: .message)
let tempListActions: [Action?] = [
.openMovePanel,
spamAction,
unread ? .markAsRead : .markAsUnread,
spamAction,
isFromMe || isInSpamFolder ? nil : .phishing,
isFromMe || isInSpamFolder ? nil : .blockList,
.shareMailLink,
archive ? .archive : .moveToInbox,
star ? .unstar : .star,
print ? .print : nil,
.shareMailLink,
platformDetector.isMac ? nil : .saveThreadInkDrive,
userIsStaff ? .reportDisplayProblem : nil
]
Expand All @@ -149,15 +151,18 @@ extension Action: CaseIterable {

let snoozedActions = snoozedActions(messages, folder: originFolder)

let isSelfThread = isSelfThread(messages, userEmail)
let isInSpamFolder = originFolder?.role == .spam
var spamAction: Action? {
let selfThread = messages.flatMap(\.from).allSatisfy { $0.isMe(currentMailboxEmail: userEmail) }
guard !selfThread else { return nil }
return originFolder?.role == .spam ? .nonSpam : .reportJunk
guard !isSelfThread else { return nil }
return isInSpamFolder ? .nonSpam : .spam
}
let star = messages.allSatisfy(\.flagged)

let tempListActions: [Action?] = [
spamAction,
isSelfThread || isInSpamFolder ? nil : .phishing,
isSelfThread || isInSpamFolder ? nil : .blockList,
star ? .unstar : .star,
.saveThreadInkDrive
]
Expand All @@ -173,17 +178,20 @@ extension Action: CaseIterable {
let unread = messages.allSatisfy(\.seen)
let showUnstar = messages.contains { $0.flagged }

let isSelfThread = isSelfThread(messages, userEmail)
let isInSpamFolder = originFolder?.role == .spam
var spamAction: Action? {
let selfThread = messages.flatMap(\.from).allSatisfy { $0.isMe(currentMailboxEmail: userEmail) }
guard !selfThread else { return nil }
return originFolder?.role == .spam ? .nonSpam : .reportJunk
guard !isSelfThread else { return nil }
return isInSpamFolder ? .nonSpam : .spam
}

let snoozedActions = snoozedActions(messages, folder: originFolder)
let tempListActions: [Action?] = [
.openMovePanel,
spamAction,
unread ? .markAsUnread : .markAsRead,
spamAction,
isSelfThread || isInSpamFolder ? nil : .phishing,
isSelfThread || isInSpamFolder ? nil : .blockList,
archive ? .archive : .moveToInbox,
showUnstar ? .unstar : .star,
.saveThreadInkDrive
Expand All @@ -206,6 +214,10 @@ extension Action: CaseIterable {
}
}

private static func isSelfThread(_ messages: [Message], _ userEmail: String) -> Bool {
return messages.flatMap(\.from).allSatisfy { $0.isMe(currentMailboxEmail: userEmail) }
}

public static func actionsForMessages(_ messages: [Message],
origin: ActionOrigin,
userIsStaff: Bool,
Expand Down Expand Up @@ -351,12 +363,6 @@ public extension Action {
iconResource: MailResourcesAsset.printText,
matomoName: "print"
)
static let reportJunk = Action(
id: "reportJunk",
title: MailResourcesStrings.Localizable.actionReportJunk,
iconResource: MailResourcesAsset.report,
matomoName: "reportJunk"
)
static let spam = Action(
id: "spam",
title: MailResourcesStrings.Localizable.actionSpam,
Expand Down
5 changes: 0 additions & 5 deletions MailCore/Cache/Actions/ActionOrigin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public struct ActionOrigin {
private(set) var nearestMessagesToMoveSheet: Binding<[Message]?>?
private(set) var nearestBlockSenderAlert: Binding<BlockRecipientAlertState?>?
private(set) var nearestBlockSendersList: Binding<BlockRecipientState?>?
private(set) var nearestReportJunkMessagesActionsPanel: Binding<[Message]?>?
private(set) var nearestReportedForPhishingMessagesAlert: Binding<[Message]?>?
private(set) var nearestReportedForDisplayProblemMessageAlert: Binding<Message?>?
private(set) var nearestShareMailLinkPanel: Binding<ShareMailLinkResult?>?
Expand All @@ -58,7 +57,6 @@ public struct ActionOrigin {
nearestMessagesToMoveSheet: Binding<[Message]?>? = nil,
nearestBlockSenderAlert: Binding<BlockRecipientAlertState?>? = nil,
nearestBlockSendersList: Binding<BlockRecipientState?>? = nil,
nearestReportJunkMessagesActionsPanel: Binding<[Message]?>? = nil,
nearestReportedForPhishingMessagesAlert: Binding<[Message]?>? = nil,
nearestReportedForDisplayProblemMessageAlert: Binding<Message?>? = nil,
nearestShareMailLinkPanel: Binding<ShareMailLinkResult?>? = nil,
Expand All @@ -72,7 +70,6 @@ public struct ActionOrigin {
self.nearestMessagesToMoveSheet = nearestMessagesToMoveSheet
self.nearestBlockSenderAlert = nearestBlockSenderAlert
self.nearestBlockSendersList = nearestBlockSendersList
self.nearestReportJunkMessagesActionsPanel = nearestReportJunkMessagesActionsPanel
self.nearestReportedForPhishingMessagesAlert = nearestReportedForPhishingMessagesAlert
self.nearestReportedForDisplayProblemMessageAlert = nearestReportedForDisplayProblemMessageAlert
self.nearestShareMailLinkPanel = nearestShareMailLinkPanel
Expand All @@ -91,7 +88,6 @@ public struct ActionOrigin {
nearestMessagesToMoveSheet: Binding<[Message]?>? = nil,
nearestBlockSenderAlert: Binding<BlockRecipientAlertState?>? = nil,
nearestBlockSendersList: Binding<BlockRecipientState?>? = nil,
nearestReportJunkMessagesActionsPanel: Binding<[Message]?>? = nil,
nearestReportedForPhishingMessagesAlert: Binding<[Message]?>? = nil,
nearestReportedForDisplayProblemMessageAlert: Binding<Message?>? = nil,
nearestShareMailLinkPanel: Binding<ShareMailLinkResult?>? = nil,
Expand All @@ -104,7 +100,6 @@ public struct ActionOrigin {
nearestMessagesToMoveSheet: nearestMessagesToMoveSheet,
nearestBlockSenderAlert: nearestBlockSenderAlert,
nearestBlockSendersList: nearestBlockSendersList,
nearestReportJunkMessagesActionsPanel: nearestReportJunkMessagesActionsPanel,
nearestReportedForPhishingMessagesAlert: nearestReportedForPhishingMessagesAlert,
nearestReportedForDisplayProblemMessageAlert: nearestReportedForDisplayProblemMessageAlert,
nearestShareMailLinkPanel: nearestShareMailLinkPanel,
Expand Down
4 changes: 0 additions & 4 deletions MailCore/Cache/Actions/ActionsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
// Needed to be sure that the bottomView is dismissed before we try to show the printPanel
DispatchQueue.main.asyncAfter(deadline: UIConstants.modalCloseDelay) {
let nc = NotificationCenter.default
nc.post(name: Notification.Name.printNotification, object: message)

Check warning on line 174 in MailCore/Cache/Actions/ActionsManager.swift

View workflow job for this annotation

GitHub Actions / Build and Test project

capture of 'message' with non-Sendable type 'Message' in a '@sendable' closure

Check warning on line 174 in MailCore/Cache/Actions/ActionsManager.swift

View workflow job for this annotation

GitHub Actions / UI Tests

capture of 'message' with non-Sendable type 'Message' in a '@sendable' closure
}
case .moveToInbox, .nonSpam:
try await performMove(messages: messagesWithDuplicates, from: origin.frozenFolder, to: .inbox)
Expand All @@ -179,10 +179,6 @@
Task { @MainActor in
origin.nearestMessagesActionsPanel?.wrappedValue = messagesWithDuplicates
}
case .reportJunk:
Task { @MainActor in
origin.nearestReportJunkMessagesActionsPanel?.wrappedValue = messagesWithDuplicates
}
case .spam:
let messagesFromFolder = messagesWithDuplicates.fromFolderOrSearch(originFolder: origin.frozenFolder)

Expand Down
Loading
Loading