Repository navigation
Hide Huddles in mobile agent DMs #6676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
6f729de
8dc0655
61918cc
91bc8b5
e2130c4
7ffb04b
2f02577
1149640
8841a57
b704ab5
ad69d06
a5025dc
8b9a126
26e83d2
43d36bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,7 @@ Future<void> _preloadMembers(WidgetRef ref, String channelId) async { | |
| final members = await ref.read(channelMembersProvider(channelId).future); | ||
| final pubkeys = members.map((m) => m.pubkey).toList(); | ||
| if (pubkeys.isNotEmpty) { | ||
| notifier.preload(pubkeys); | ||
| await notifier.preload(pubkeys); | ||
| } | ||
| } catch (_) { | ||
| // Non-fatal — mentions will just fall back to cache from messages. | ||
|
|
@@ -146,6 +146,16 @@ int? _channelReadTimestamp({ | |
| return dateTimeToUnixSeconds(channel.lastMessageAt); | ||
| } | ||
|
|
||
| bool _isOneToOneAgentDm(Channel channel, Set<String> agentPubkeys) { | ||
| final participants = channel.participantPubkeys | ||
| .map((pubkey) => pubkey.trim().toLowerCase()) | ||
| .where((pubkey) => pubkey.isNotEmpty) | ||
| .toSet(); | ||
| return channel.isDm && | ||
| participants.length == 2 && | ||
| participants.any(agentPubkeys.contains); | ||
| } | ||
|
|
||
| /// Controls how a hydrated initial thread is added to the navigation stack. | ||
| enum InitialThreadRouteBehavior { | ||
| /// Keep the channel route beneath the thread. | ||
|
|
@@ -256,10 +266,54 @@ class ChannelDetailPage extends HookConsumerWidget { | |
| channel; | ||
| final resolvedChannel = | ||
| detailsAsync.whenData(baseChannel.mergeDetails).value ?? baseChannel; | ||
| final memberProfilesPreload = useMemoized( | ||
| () => _preloadMembers(ref, resolvedChannel.id), | ||
| [resolvedChannel.id, sessionStatus], | ||
| ); | ||
| final memberProfilesPreloadState = useFuture(memberProfilesPreload); | ||
| final showsComposer = | ||
| !resolvedChannel.isForum && | ||
| resolvedChannel.isMember && | ||
| !resolvedChannel.isArchived; | ||
| final profileOwnedAgentPubkeys = <String>[]; | ||
| for (final participantPubkey in resolvedChannel.participantPubkeys) { | ||
| final normalized = participantPubkey.trim().toLowerCase(); | ||
| final isProfileOwnedAgent = ref.watch( | ||
| userCacheProvider.select( | ||
| (cache) => cache[normalized]?.ownerPubkey != null, | ||
| ), | ||
| ); | ||
| if (isProfileOwnedAgent) profileOwnedAgentPubkeys.add(normalized); | ||
| } | ||
| final agentDirectoryState = ref.watch(agentDirectoryProvider); | ||
| final agentOwnersState = ref.watch(agentOwnersProvider); | ||
|
klopez4212 marked this conversation as resolved.
|
||
| final channelBotPubkeysState = ref.watch( | ||
| channelBotPubkeysProvider(resolvedChannel.id), | ||
| ); | ||
|
klopez4212 marked this conversation as resolved.
|
||
| final agentPubkeys = agentPubkeysWithChannelBots( | ||
| knownAgentPubkeys: agentPubkeysWithProfileOwners( | ||
| knownAgentPubkeys: ref.watch(knownAgentPubkeysProvider), | ||
| profileOwnedAgentPubkeys: profileOwnedAgentPubkeys, | ||
|
klopez4212 marked this conversation as resolved.
Outdated
|
||
| ), | ||
| channelBotPubkeys: | ||
| channelBotPubkeysState.asData?.value ?? const <String>{}, | ||
| ); | ||
| final participantCount = resolvedChannel.participantPubkeys | ||
| .map((pubkey) => pubkey.trim().toLowerCase()) | ||
| .where((pubkey) => pubkey.isNotEmpty) | ||
| .toSet() | ||
| .length; | ||
| final isOneToOneDm = resolvedChannel.isDm && participantCount == 2; | ||
| final isAgentIdentityLoading = | ||
| isOneToOneDm && | ||
| (agentDirectoryState.isLoading || | ||
| agentOwnersState.isLoading || | ||
| channelBotPubkeysState.isLoading || | ||
| memberProfilesPreloadState.connectionState != ConnectionState.done); | ||
|
klopez4212 marked this conversation as resolved.
Outdated
|
||
| final showsHuddleAction = | ||
| showsComposer && | ||
| !isAgentIdentityLoading && | ||
| !_isOneToOneAgentDm(resolvedChannel, agentPubkeys); | ||
| final messagesNotifier = ref.read( | ||
| channelMessagesProvider(channel.id).notifier, | ||
| ); | ||
|
|
@@ -301,12 +355,6 @@ class ChannelDetailPage extends HookConsumerWidget { | |
| return session.registerVisibleChannel(channel.id); | ||
| }, [channel.id]); | ||
|
|
||
| // Preload channel member profiles so @mentions resolve correctly. | ||
| useEffect(() { | ||
| _preloadMembers(ref, channel.id); | ||
| return null; | ||
| }, [channel.id]); | ||
|
|
||
| useEffect( | ||
| () { | ||
| if (channel.isForum) return null; | ||
|
|
@@ -394,7 +442,7 @@ class ChannelDetailPage extends HookConsumerWidget { | |
| ), | ||
| actions: resolvedChannel.isDm | ||
| ? [ | ||
| if (showsComposer) | ||
| if (showsHuddleAction) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an agent DM already contains an active Useful? React with 👍 / 👎. |
||
| _HuddleButton( | ||
| channel: resolvedChannel, | ||
| events: [ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.