Skip to content

Commit

Permalink
Show toast & manage optional unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-nirali-s committed Dec 17, 2024
1 parent 0903ef1 commit e4c756d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Splito.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
D85E86E22BAB06D9002EDF76 /* AddExpenseViewModel.swift */,
D85E86F02BB41CBA002EDF76 /* Detail Selection */,
D856C7302BCFD2080008A341 /* Expense Detail */,
D8CD952A2BD65E6400407B47 /* Expense Split Option */,
210CC0392CF6DA7F0035682E /* Note */,
);
path = Expense;
Expand All @@ -525,6 +524,7 @@
D85E86EC2BB41B87002EDF76 /* SelectGroupView.swift */,
D85E86EE2BB41B9F002EDF76 /* SelectGroupViewModel.swift */,
21BA6D4B2C3BB64B0020ED04 /* Payer */,
D8CD952A2BD65E6400407B47 /* Expense Split Option */,
);
path = "Detail Selection";
sourceTree = "<group>";
Expand Down
7 changes: 4 additions & 3 deletions Splito/UI/Home/Expense/AddExpenseViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ extension AddExpenseViewModel {
self.showToastFor(toast: ToastPrompt(type: .warning, title: "Whoops!", message: "Please select a group to get payer list."))
return
}
if let userId = preference.user?.id, selectedPayers == [:] || selectedPayers[userId] == 0 {

if let userId = preference.user?.id, selectedPayers == [:] || (selectedPayers[userId] ?? 0) == 0 {
selectedPayers = [userId: expenseAmount]
}
showPayerSelection = true
Expand Down Expand Up @@ -320,8 +321,8 @@ extension AddExpenseViewModel {
}

func handleSaveAction() async -> Bool {
if let userId = preference.user?.id, selectedPayers == [:] || selectedPayers[userId] == 0 ||
(selectedPayers.count == 1 && selectedPayers[userId] != expenseAmount) {
if let userId = preference.user?.id, selectedPayers == [:] || (selectedPayers[userId] ?? 0) == 0 ||
(selectedPayers.count == 1 && (selectedPayers[userId] ?? 0) != expenseAmount) {
selectedPayers = [userId: expenseAmount]
}

Expand Down
1 change: 1 addition & 0 deletions Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class EmailLoginViewModel: BaseViewModel, ObservableObject {
} catch {
isLoginInProgress = false
LogE("EmailLoginViewModel: \(#function) Error fetching user: \(error).")
showToastForError()
}
}
}
Expand Down

0 comments on commit e4c756d

Please sign in to comment.