Skip to content

Commit

Permalink
#2367 Show move to inbox button for all cases when it's not inbox (#…
Browse files Browse the repository at this point in the history
…2380)

* show move to inbox button for all cases when it's not inbox

* fix: pr reviews

* fix: pr reviews
  • Loading branch information
ioanmo226 authored Oct 2, 2023
1 parent 15487c3 commit 8347176
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
9 changes: 0 additions & 9 deletions FlowCrypt/Controllers/Inbox/InboxItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ extension InboxItem {
messages.count == 1 && labels.contains(.draft)
}

var shouldShowMoveToInboxButton: Bool {
guard let firstMessageLabels = messages.first?.labels else {
return false
}
// Thread is treated as archived when labels don't contain `inbox` and first message label doesn't contain sent label
// https://github.com/FlowCrypt/flowcrypt-ios/pull/1769#discussion_r931874353
return !isInbox && !firstMessageLabels.contains(.sent)
}

var isRead: Bool {
!messages.contains(where: { !$0.isRead })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,15 @@ extension InboxViewController {
case .moveToTrash, .permanentlyDelete:
removeMessage(at: indexToUpdate)
case .archive, .moveToInbox:
if path.isEmpty { // no need to remove in 'All Mail' folder
if path == "INBOX" { // Remove messages in inbox folder
removeMessage(at: indexToUpdate)
} else {
updateMessage(
labelsToAdd: action == .moveToInbox ? [.inbox] : [],
labelsToRemove: action == .archive ? [.inbox] : [],
at: indexToUpdate,
resetThreadSelect: resetThreadSelect
)
} else {
removeMessage(at: indexToUpdate)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ extension MessageActionsHandler where Self: UIViewController {
actions = [.moveToTrash]
default:
actions = [.moveToTrash, .markAsUnread]
if inboxItem.isInbox {
actions.insert(.archive, at: 0)
} else if inboxItem.shouldShowMoveToInboxButton {
actions.insert(.moveToInbox, at: 0)
}
actions.insert(inboxItem.isInbox ? .archive : .moveToInbox, at: 0)
}

let items = [helpButton] + actions.map { createNavigationBarButton(action: $0) }
Expand Down

0 comments on commit 8347176

Please sign in to comment.