Ensure notification profile visibility updates on all tabs.

Resolve #13945
This commit is contained in:
Sagar
2025-01-27 01:41:11 +05:30
committed by Greyson Parrelli
parent 0e4f191304
commit 4369591966
4 changed files with 16 additions and 13 deletions

View File

@@ -1023,7 +1023,6 @@ public class ConversationListFragment extends MainFragment implements ActionMode
lifecycleDisposable.add(viewModel.getMegaphoneState().subscribe(this::onMegaphoneChanged));
lifecycleDisposable.add(viewModel.getConversationsState().subscribe(this::onConversationListChanged));
lifecycleDisposable.add(viewModel.getHasNoConversations().subscribe(this::updateEmptyState));
lifecycleDisposable.add(viewModel.getNotificationProfiles().subscribe(profiles -> requireCallback().updateNotificationProfileStatus(profiles)));
lifecycleDisposable.add(viewModel.getWebSocketState().subscribe(pipeState -> requireCallback().updateProxyStatus(pipeState)));
lifecycleDisposable.add(viewModel.getChatFolderState().subscribe(this::onChatFoldersChanged));
@@ -2035,8 +2034,6 @@ public class ConversationListFragment extends MainFragment implements ActionMode
@NonNull Stub<Toolbar> getBasicToolbar();
void updateNotificationProfileStatus(@NonNull List<NotificationProfile> notificationProfiles);
void updateProxyStatus(@NonNull WebSocketConnectionState state);
void onMultiSelectStarted();

View File

@@ -17,7 +17,6 @@ import org.signal.paging.PagingConfig
import org.signal.paging.ProxyPagingController
import org.thoughtcrime.securesms.components.settings.app.chats.folders.ChatFolderRecord
import org.thoughtcrime.securesms.components.settings.app.chats.folders.ChatFoldersRepository
import org.thoughtcrime.securesms.components.settings.app.notifications.profiles.NotificationProfilesRepository
import org.thoughtcrime.securesms.conversationlist.chatfilter.ConversationFilterRequest
import org.thoughtcrime.securesms.conversationlist.chatfilter.ConversationFilterSource
import org.thoughtcrime.securesms.conversationlist.model.Conversation
@@ -31,7 +30,6 @@ import org.thoughtcrime.securesms.megaphone.Megaphone
import org.thoughtcrime.securesms.megaphone.MegaphoneRepository
import org.thoughtcrime.securesms.megaphone.Megaphones
import org.thoughtcrime.securesms.notifications.MarkReadReceiver
import org.thoughtcrime.securesms.notifications.profiles.NotificationProfile
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.util.rx.RxStore
@@ -40,8 +38,7 @@ import java.util.concurrent.TimeUnit
class ConversationListViewModel(
private val isArchived: Boolean,
private val megaphoneRepository: MegaphoneRepository = AppDependencies.megaphoneRepository,
private val notificationProfilesRepository: NotificationProfilesRepository = NotificationProfilesRepository()
private val megaphoneRepository: MegaphoneRepository = AppDependencies.megaphoneRepository
) : ViewModel() {
companion object {
@@ -241,11 +238,6 @@ class ConversationListViewModel(
}
}
fun getNotificationProfiles(): Flowable<List<NotificationProfile>> {
return notificationProfilesRepository.getProfiles()
.observeOn(AndroidSchedulers.mainThread())
}
private fun setSelection(newSelection: Collection<Conversation>) {
store.update {
val selection = newSelection.toSet()

View File

@@ -108,6 +108,10 @@ class MainActivityListHostFragment : Fragment(R.layout.main_activity_list_host_f
R.id.callLogFragment -> goToStateFromCalling(state, controller)
}
}
disposables += conversationListTabsViewModel.getNotificationProfiles().subscribeBy { profiles ->
updateNotificationProfileStatus(profiles)
}
}
private fun goToStateFromConversationList(state: ConversationListTabsState, navController: NavController) {
@@ -314,7 +318,7 @@ class MainActivityListHostFragment : Fragment(R.layout.main_activity_list_host_f
}
}
override fun updateNotificationProfileStatus(notificationProfiles: List<NotificationProfile>) {
private fun updateNotificationProfileStatus(notificationProfiles: List<NotificationProfile>) {
val activeProfile = NotificationProfiles.getActiveProfile(notificationProfiles)
if (activeProfile != null) {
if (activeProfile.id != SignalStore.notificationProfile.lastProfilePopup) {

View File

@@ -10,10 +10,15 @@ import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.kotlin.plusAssign
import io.reactivex.rxjava3.subjects.PublishSubject
import io.reactivex.rxjava3.subjects.Subject
import org.thoughtcrime.securesms.components.settings.app.notifications.profiles.NotificationProfilesRepository
import org.thoughtcrime.securesms.notifications.profiles.NotificationProfile
import org.thoughtcrime.securesms.stories.Stories
import org.thoughtcrime.securesms.util.rx.RxStore
class ConversationListTabsViewModel(startingTab: ConversationListTab, repository: ConversationListTabRepository) : ViewModel() {
private val notificationProfilesRepository: NotificationProfilesRepository = NotificationProfilesRepository()
private val store = RxStore(ConversationListTabsState(tab = startingTab))
val stateSnapshot: ConversationListTabsState
@@ -47,6 +52,11 @@ class ConversationListTabsViewModel(startingTab: ConversationListTab, repository
disposables.clear()
}
fun getNotificationProfiles(): Flowable<List<NotificationProfile>> {
return notificationProfilesRepository.getProfiles()
.observeOn(AndroidSchedulers.mainThread())
}
fun onChatsSelected() {
internalTabClickEvents.onNext(ConversationListTab.CHATS)
performStoreUpdate { it.copy(tab = ConversationListTab.CHATS) }