Skip to content

Commit

Permalink
Fixes #13312: Delegate onConfigurationChanged to the ViewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
dautovicharis committed Dec 8, 2023
1 parent 71f9474 commit 3627679
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
onMegaphoneChanged(viewModel.getMegaphone());
viewModel.onConfigurationChanged();
}

private ContactSearchConfiguration mapSearchStateToConfiguration(@NonNull ContactSearchState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ class ConversationListViewModel(
}
}

fun onConfigurationChanged() {
megaphoneRepository.getNextMegaphone { next ->
store.update { it.copy(megaphone = next ?: Megaphone.NONE) }
}
}

private data class ConversationListState(
val conversations: List<Conversation> = emptyList(),
val megaphone: Megaphone = Megaphone.NONE,
Expand Down

0 comments on commit 3627679

Please sign in to comment.