Skip to content

Commit

Permalink
IOS-2655 Fix toast
Browse files Browse the repository at this point in the history
  • Loading branch information
mgolovko committed Apr 11, 2024
1 parent 5f4707c commit f346746
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct UndoRedoView: View {
)
}
}
.snackbar(toastBarData: $model.toastData)
.padding(.init(top: 8, leading: 16, bottom: 0, trailing: 16))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ final class UndoRedoViewModel: ObservableObject {

private let objectId: String

@Published var toastData: ToastBarData = .empty

init(
objectId: String
) {
Expand All @@ -18,11 +20,19 @@ final class UndoRedoViewModel: ObservableObject {

func undo() async throws {
AnytypeAnalytics.instance().logUndo()
try await objectActionsService.undo(objectId: objectId)
do {
try await objectActionsService.undo(objectId: objectId)
} catch let error as ObjectActionsServiceError {
toastData = ToastBarData(text: error.localizedDescription, showSnackBar: true, messageType: .none)
}
}

func redo() async throws {
AnytypeAnalytics.instance().logRedo()
try await objectActionsService.redo(objectId: objectId)
do {
AnytypeAnalytics.instance().logRedo()
try await objectActionsService.redo(objectId: objectId)
} catch let error as ObjectActionsServiceError {
toastData = ToastBarData(text: error.localizedDescription, showSnackBar: true, messageType: .none)
}
}
}

0 comments on commit f346746

Please sign in to comment.