Move mute handling into ConversationViewModel.

This commit is contained in:
Alex Hart
2023-03-20 13:49:19 -03:00
committed by Greyson Parrelli
parent 2a43ffad4f
commit 30f6faf3d7
3 changed files with 9 additions and 10 deletions

View File

@@ -1088,16 +1088,7 @@ public class ConversationParentFragment extends Fragment
@Override
public void handleMuteNotifications() {
MuteDialog.show(requireActivity(), until -> {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
SignalDatabase.recipients().setMuted(recipient.getId(), until);
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
});
MuteDialog.show(requireActivity(), viewModel::muteConversation);
}
private void handleStoryRingClick() {

View File

@@ -212,4 +212,8 @@ class ConversationRepository {
}
});
}
public void setConversationMuted(@NonNull RecipientId recipientId, long until) {
SignalExecutors.BOUNDED.execute(() -> SignalDatabase.recipients().setMuted(recipientId, until));
}
}

View File

@@ -338,6 +338,10 @@ public class ConversationViewModel extends ViewModel {
return conversationStateStore.getState().getSecurityInfo().isPushAvailable();
}
void muteConversation(long until) {
conversationRepository.setConversationMuted(args.getRecipientId(), until);
}
@NonNull ConversationState getConversationStateSnapshot() {
return conversationStateStore.getState();
}