Skip to content

Commit f70cb43

Browse files
style: Clean code
1 parent 10a7c50 commit f70cb43

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

Mail/Views/New Message/ComposeMessageView.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,12 @@ struct ComposeMessageView: View {
338338
}
339339

340340
private func didScheduleDraft(_ date: Date) {
341-
draft.action = .schedule
342-
draft.date = date
341+
if let liveDraft = draft.thaw() {
342+
try? liveDraft.realm?.write {
343+
liveDraft.scheduleDate = date
344+
liveDraft.action = .schedule
345+
}
346+
}
343347

344348
dismissMessageView()
345349
}
@@ -353,7 +357,7 @@ struct ComposeMessageView: View {
353357

354358
let mailbox = mailboxManager.mailbox
355359
let mailboxIsFull = mailbox.quotas?.progression ?? 0 >= 1
356-
if mailbox.isFree && mailbox.isLimited && mailboxIsFull {
360+
if mailbox.isMyKSuiteFree && mailboxIsFull {
357361
matomo.track(eventWithCategory: .newMessage, name: "trySendingWithMailboxFull")
358362
Task {
359363
if let liveDraft = draft.thaw() {

Mail/Views/Schedule/ScheduleFloatingPanel.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct ScheduleFloatingPanel: ViewModifier {
7474
isShowingCustomScheduleAlert: $isShowingCustomScheduleAlert,
7575
isShowingMyKSuiteUpgrade: $isShowingMyKSuiteUpgrade,
7676
type: type,
77-
setScheduleAction: completionHandler
77+
completionHandler: completionHandler
7878
)
7979
}
8080
.customAlert(isPresented: $isShowingCustomScheduleAlert) {
@@ -90,9 +90,4 @@ struct ScheduleFloatingPanel: ViewModifier {
9090
}
9191
.myKSuitePanel(isPresented: $isShowingMyKSuiteUpgrade, configuration: .mail)
9292
}
93-
94-
private func setSchedule(_ scheduleDate: Date) {
95-
// draftSaveOption = .schedule
96-
// draftDate = scheduleDate
97-
}
9893
}

Mail/Views/Schedule/ScheduleFloatingPanelView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct ScheduleFloatingPanelView: View {
2727
@Binding var isShowingMyKSuiteUpgrade: Bool
2828

2929
let type: ScheduleType
30-
let setScheduleAction: (Date) -> Void
30+
let completionHandler: (Date) -> Void
3131

3232
private var scheduleOptions: [ScheduleSendOption] {
3333
let lastScheduledDate = UserDefaults.shared[keyPath: type.lastCustomScheduleDateKeyPath]
@@ -40,7 +40,7 @@ struct ScheduleFloatingPanelView: View {
4040
var body: some View {
4141
VStack(spacing: 0) {
4242
ForEach(scheduleOptions) { option in
43-
ScheduleOptionView(type: type, option: option, setScheduleAction: setScheduleAction)
43+
ScheduleOptionView(type: type, option: option, completionHandler: completionHandler)
4444

4545
IKDivider(type: .item)
4646
}

Mail/Views/Schedule/ScheduleOptionView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct ScheduleOptionView: View {
3030

3131
let type: ScheduleType
3232
let option: ScheduleSendOption
33-
let setScheduleAction: (Date) -> Void
33+
let completionHandler: (Date) -> Void
3434

3535
var body: some View {
3636
if let scheduleDate = option.date {
@@ -55,7 +55,7 @@ struct ScheduleOptionView: View {
5555
guard let scheduleDate = option.date else { return }
5656

5757
matomo.track(eventWithCategory: type.matomoCategory, name: option.matomoName)
58-
setScheduleAction(scheduleDate)
58+
completionHandler(scheduleDate)
5959
dismiss()
6060
}
6161
}

0 commit comments

Comments
 (0)