Skip to content

Commit c83e239

Browse files
authored
fix(chat): open the group's profile from an invite card (#1736)
Tapping a group invite card in a transcript opened the group's chat, skipping the profile (cover, members, balance requirements) that the card previews. A resolved card now pushes the group's profile, the way a featured group does: the chat route opens on the profile, and Open Chat there pushes the transcript. A card that is still loading or unavailable keeps opening the chat by id. A link to the chat already on screen still does nothing, and the invite-followed analytics event is unchanged. GroupLinkLookup hands the public record it fetched to FeaturedGroupsStore, so the profile draws from it instead of sitting empty through its own GetChat. The group profile has no origin parameter on Android (it reads whether a chat is underneath), so no new origin value is needed.
1 parent c7dc126 commit c83e239

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

‎apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/link/GroupLinkLookup.kt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.flipcash.services.controllers.ChatController
99
import com.flipcash.services.models.chat.ChatId
1010
import com.flipcash.services.models.chat.ChatType
1111
import com.flipcash.services.models.chat.ViewMode
12+
import com.flipcash.shared.chat.FeaturedGroupsStore
1213
import com.flipcash.shared.chat.models.LinkCard
1314
import com.getcode.solana.keys.Mint
1415
import com.getcode.util.resources.ResourceHelper
@@ -25,6 +26,9 @@ import javax.inject.Inject
2526
* Anything that is not a group -- a DM id pasted into a `/chat/` link, or a chat that has gone --
2627
* fails the lookup, and the card draws its unavailable state.
2728
*
29+
* A resolved record is also handed to [FeaturedGroupsStore], so the profile a tap opens has
30+
* something to draw before its own fetch answers.
31+
*
2832
* The requirement is stated the way the chat's own head card states it, including the reserve
2933
* being named by the amount alone ("$100", not "$100 of Dollars"). An unknown mint is not a
3034
* failure: the amount is still true, so it is stated without a token beside it.
@@ -33,12 +37,17 @@ internal class GroupLinkLookup @Inject constructor(
3337
private val chatController: ChatController,
3438
private val tokenCoordinator: TokenCoordinator,
3539
private val resources: ResourceHelper,
40+
private val featuredGroups: FeaturedGroupsStore,
3641
) {
3742
suspend operator fun invoke(chatId: ChatId): Result<LinkCard.GroupInvite.State.Resolved> =
3843
runCatching {
3944
val chat = chatController.getChat(chatId, ViewMode.REDACTED).getOrThrow()
4045
if (chat.type != ChatType.GROUP) throw NotAGroup(chatId)
4146

47+
// A tap opens the group's profile, which draws from this record at once rather than
48+
// sitting empty through its own GetChat -- the same placeholder a featured group gets.
49+
featuredGroups.remember(listOf(chat))
50+
4251
val balance = chat.rules.balanceRequirement()
4352
val staffOnly = chat.rules.requiresStaff()
4453
val requirement = if (balance != null || staffOnly) {

‎apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/screens/MessengerScreen.kt‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,15 @@ internal fun MessengerScreen(viewModel: ChatViewModel) {
190190
keyboard.hideIfVisible {
191191
viewModel.dispatchEvent(
192192
ChatViewModel.Event.OpenScreen(
193-
// Pushed, so Back returns to this chat. The pushed screen gates
194-
// itself: a non-member sees the join or the buy there.
195-
AppRoute.Messaging.Chat(ChatIdentifier.ByChatId(action.chatId))
193+
// Pushed, so Back returns to this chat. A resolved card opens
194+
// the group's profile, as a featured group does: Open Chat there
195+
// pushes the transcript, which gates itself for a non-member.
196+
// Until the card resolves there is no record to show, so it opens
197+
// the chat.
198+
AppRoute.Messaging.Chat(
199+
identifier = ChatIdentifier.ByChatId(action.chatId),
200+
openOnProfile = action.resolved,
201+
)
196202
)
197203
)
198204
}

‎apps/flipcash/shared/chat-ui/src/main/kotlin/com/flipcash/shared/chat/models/ChatAction.kt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ sealed interface ChatAction {
3535
/**
3636
* Opens the group a link card names, pushed over this chat so Back returns here. The pushed
3737
* screen gates itself; a card never joins or buys on the reader's behalf.
38+
*
39+
* [resolved] is whether the card has fetched the group's public record. A resolved card opens
40+
* the group's profile, a card still loading or unavailable opens the chat itself.
3841
*/
39-
data class OpenGroup(val chatId: ChatId) : ChatAction
42+
data class OpenGroup(val chatId: ChatId, val resolved: Boolean) : ChatAction
4043

4144
/**
4245
* Opens the person a link card names: their DM, pushed over this chat so Back returns here, or

‎apps/flipcash/shared/chat-ui/src/main/kotlin/com/flipcash/shared/chat/ui/MessageBubble.kt‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,8 @@ private fun BareLinkCard(
734734
* app, wrong from inside a chat, where it swaps the transcript for the wallet on the way to a
735735
* screen the reader asked for directly. There is no wallet card here for the detail to grow out of.
736736
* So it pushes, exactly as the cash bubble's own token tap does, and back returns to the message.
737-
* A group invite pushes the group's conversation for the same reason.
737+
* A group invite pushes the group's profile (its conversation until the card has resolved) for
738+
* the same reason.
738739
*/
739740
@Composable
740741
private fun rememberLinkCardClick(): (LinkCard) -> Unit {
@@ -749,7 +750,12 @@ private fun rememberLinkCardClick(): (LinkCard) -> Unit {
749750
is LinkCard.TokenInfo -> actionHandler(ChatAction.ViewToken(card.mint))
750751
// Pushed over this chat rather than through the chat deep link, which replaces the
751752
// stack: Back has to return to the message that held the invite.
752-
is LinkCard.GroupInvite -> actionHandler(ChatAction.OpenGroup(card.chatId))
753+
is LinkCard.GroupInvite -> actionHandler(
754+
ChatAction.OpenGroup(
755+
chatId = card.chatId,
756+
resolved = card.state is LinkCard.GroupInvite.State.Resolved,
757+
)
758+
)
753759
// Only a resolved card takes a tap. Which screen it opens -- the person's DM, your own
754760
// tip card, or nothing for the person already on the other end -- is the chat's call.
755761
is LinkCard.User -> (card.state as? LinkCard.User.State.Resolved)?.let {

0 commit comments

Comments
 (0)