Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Dismiss RoleInviteFragment after invitation is sent #1721

Merged
merged 1 commit into from
Jun 15, 2019
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 @@ -66,6 +66,7 @@ public void onStart() {
roleInviteViewModel.getProgress().observe(this, this::showProgress);
roleInviteViewModel.getSuccess().observe(this, this::onSuccess);
roleInviteViewModel.getError().observe(this, this::showError);
roleInviteViewModel.getDismiss().observe(this, (dismiss) -> dismiss());
binding.setRoleInvite(roleInviteViewModel.getRoleInvite());
setUpSpinner();
}
Expand Down Expand Up @@ -96,4 +97,8 @@ public void onSuccess(String message) {
public void showProgress(boolean show) {
showView(binding.progressBar, show);
}

public void dismiss() {
getFragmentManager().popBackStack();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class RoleInviteViewModel extends ViewModel {
private final SingleEventLiveData<Boolean> progress = new SingleEventLiveData<>();
private final SingleEventLiveData<String> error = new SingleEventLiveData<>();
private final SingleEventLiveData<String> success = new SingleEventLiveData<>();
private final SingleEventLiveData<Void> dismiss = new SingleEventLiveData<>();

@Inject
public RoleInviteViewModel(RoleRepository roleRepository) {
Expand All @@ -47,6 +48,10 @@ public LiveData<String> getError() {
return error;
}

public LiveData<Void> getDismiss() {
return dismiss;
}

public void createRoleInvite(long roleId) {

long eventId = ContextManager.getSelectedEvent().getId();
Expand All @@ -63,6 +68,7 @@ public void createRoleInvite(long roleId) {
.doFinally(() -> progress.setValue(false))
.subscribe(sentRoleInvite -> {
success.setValue("Role Invite Sent");
dismiss.call();
}, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
}