Skip to content
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 @@ -4,8 +4,6 @@ import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import com.flipcash.app.core.bill.Scannable
import com.flipcash.app.core.data.Loadable
import com.flipcash.app.featureflags.FeatureFlag
import com.flipcash.app.featureflags.FeatureFlagController
import com.flipcash.app.core.extensions.onResult
import com.flipcash.app.core.tipping.TipStep
import com.flipcash.app.shareable.ShareSheetController
Expand All @@ -21,18 +19,15 @@ import com.flipcash.shared.chat.ui.toConversationReference
import com.flipcash.shared.tipping.TippingCoordinator
import com.getcode.util.resources.ResourceHelper
import com.getcode.view.BaseViewModel
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.onEach
import javax.inject.Inject

@OptIn(ExperimentalCoroutinesApi::class)
@HiltViewModel
internal class TipFlowViewModel @Inject constructor(
chatCoordinator: ChatCoordinator,
Expand All @@ -41,7 +36,6 @@ internal class TipFlowViewModel @Inject constructor(
tokenCoordinator: TokenCoordinator,
shareable: ShareSheetController,
tipCodePreviewCache: TipCodePreviewCache,
featureFlags: FeatureFlagController,
private val resources: ResourceHelper,
) : BaseViewModel<TipFlowViewModel.State, TipFlowViewModel.Event>(
initialState = State(),
Expand Down Expand Up @@ -93,14 +87,7 @@ internal class TipFlowViewModel @Inject constructor(
.launchIn(viewModelScope)

combine(
featureFlags.observe(FeatureFlag.GroupChats)
.flatMapLatest { groupsOn ->
if (groupsOn) {
chatCoordinator.feed(ChatType.TIP_DM, ChatType.GROUP)
} else {
chatCoordinator.feed(ChatType.TIP_DM)
}
},
chatCoordinator.feed(ChatType.TIP_DM, ChatType.GROUP),
tokenCoordinator.tokens,
) { summaries, tokens ->
val selfId = userManager.accountId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ class RealChatCoordinator @Inject constructor(
feedDelegate.observeFeedFromDb()
feedDelegate.syncFeed()
groupFeedDelegate.initialize(scope)
// Synced unconditionally. The GroupChats flag filters the chat list, and every read of
// this cache is already scoped to the chat types its caller asked for, so a group sitting
// in the database with the flag off is invisible rather than latent. Gating the fetch
// instead made the toggle do nothing until the process restarted, and contradicted the
// roster-change routing below, which was never gated.
groupFeedDelegate.syncGroupFeed()
eventStreamDelegate.open()
eventStreamDelegate.startHeartbeat { feedDelegate.syncFeed() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ class GroupChatRoutingTest {
subject.onUserLoggedIn(mockk<AccountCluster>(relaxed = true))
runCurrent()

// Unconditional: the GroupChats flag filters the list, it does not decide whether the
// cache is populated. Gating the fetch here made the toggle a no-op until the next launch.
coVerify { groupFeedDelegate.syncGroupFeed() }
subject.teardown()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ sealed interface FeatureFlag<T: Any> {
override val persistLogOut: Boolean = false
}

@FeatureFlagMarker
data object GroupChats: FeatureFlag<Boolean> {
override val key: String = "group_chats_enabled"
override val default: Boolean = false
override val launched: Boolean = false
override val visible: Boolean = true
override val persistLogOut: Boolean = false
}

companion object {
val entries: List<FeatureFlag<*>>
get() = FeatureFlagEntries.entries
Expand All @@ -148,7 +139,6 @@ val FeatureFlag<*>.title: String
FeatureFlag.ContactPickerMode -> "Contact Picker Mode"
FeatureFlag.ShowNetworkState -> "Network Offline Indicator"
FeatureFlag.FrostedTipCard -> "Frosted Tip Card"
FeatureFlag.GroupChats -> "Group Chats"
}

val FeatureFlag<*>.message: String
Expand All @@ -162,7 +152,6 @@ val FeatureFlag<*>.message: String
FeatureFlag.ContactPickerMode -> "When enabled, contacts will be accessed via the system contact picker instead of requesting full READ_CONTACTS permission"
FeatureFlag.ShowNetworkState -> "When enabled, you'll gain the ability to see the network state on the Scanner when offline"
FeatureFlag.FrostedTipCard -> "When enabled, the tip card in the scanner renders as frosted glass over a blurred snapshot of the camera instead of a solid card"
FeatureFlag.GroupChats -> "When enabled, group chats appear in your chat list alongside your direct messages"
}


Expand Down
Loading