Skip to content

Commit ede8d22

Browse files
tellahonpub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w
andauthored
feat(mobile): bring channel menus to desktop parity (#3940)
## Overview **Category:** improvement **User Impact:** Mobile users can now access consistent channel and DM actions from both the channel list and conversation header. **Problem:** Mobile channel menus exposed a narrower, inconsistent set of actions than desktop, and the available actions differed by entry point. **Solution:** This change introduces one reusable action sheet with a clear quick-action hierarchy, role-aware lifecycle controls, confirmations for consequential actions, and a deliberately narrower DM menu. ## Changes <details> <summary>File changes</summary> **mobile/lib/features/channels/channel_actions_sheet.dart** Adds the shared channel and DM action-sheet experience used by both entry points, including Star/Unstar and Read/Unread quick actions for channels, section movement, mute, management, inline copy actions, guarded lifecycle actions, confirmations, and a compact DM menu without quick actions. **mobile/lib/features/channels/channel_detail_page.dart** Routes the header ellipsis through the shared action sheet so the in-channel menu matches the channel-list experience, including for DMs. **mobile/lib/features/channels/channel_management_provider.dart** Adds archive and delete operations using the desktop-compatible relay event kinds and refreshes channel state after completion. **mobile/lib/features/channels/channels_page.dart** Makes the shared channel action-sheet entry point available to the channel-list implementation. **mobile/lib/features/channels/channels_page/channel_tile.dart** Replaces the tile-specific long-press menu with the reusable action sheet while preserving read state and section context. **mobile/test/features/channels/channel_actions_sheet_test.dart** Covers action hierarchy, owner/admin/member capability guards, loading and failure states, DM narrowing with no quick-action row, and inline copy actions. **mobile/test/features/channels/channel_detail_page_test.dart** Updates channel-header flows to exercise management through the new shared action sheet. **mobile/test/features/channels/channel_management_provider_test.dart** Verifies archive and delete event tags stay compatible with desktop behavior. </details> ## Reproduction Steps 1. Run the mobile app and open a populated channel list. 2. Long-press a regular channel and verify the Star/Unstar and Read/Unread quick actions appear above Move to section…, Mute, Manage, Copy channel name, and Copy channel ID. 3. Choose either copy action and verify it copies the expected value. 4. Open a channel, tap the header ellipsis, and verify the same action sheet appears. 5. As an admin or owner, verify Archive appears; as an owner, verify Delete also appears. Confirm that lifecycle actions require confirmation. 6. Long-press or open the header menu for a DM and verify it has no quick-action row and starts with Mute, followed by Copy channel name and Copy channel ID. ## Screenshots ### Channel menu | Regular channel — Mark Unread | DM — no quick actions | Archive confirmation | |---|---|---| | ![Regular channel actions with Mark Unread](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/3940/final-regular-channel-mark-unread.png) | ![DM actions without quick actions](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/3940/final-dm-no-quick-actions.png) | ![Archive confirmation](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/3940/final-archive-confirmation.png) | --------- Signed-off-by: Taylor Ho <[email protected]> Co-authored-by: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@buzz.block.builderlab.xyz>
1 parent 985cdcc commit ede8d22

8 files changed

Lines changed: 1082 additions & 232 deletions

‎mobile/lib/features/channels/channel_actions_sheet.dart‎

Lines changed: 559 additions & 0 deletions
Large diffs are not rendered by default.

‎mobile/lib/features/channels/channel_detail_page.dart‎

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ import '../profile/user_cache_provider.dart';
2525
import '../profile/user_profile.dart';
2626
import '../forum/forum_posts_view.dart';
2727
import 'channel.dart';
28+
import 'channel_actions_sheet.dart';
2829
import 'channel_link_navigation.dart';
2930
import 'agent_activity/working_bots_provider.dart';
3031
import 'channel_management_provider.dart';
32+
import 'channel_sections/channel_sections_provider.dart';
3133
import 'channel_messages_provider.dart';
3234
import 'channel_typing_provider.dart';
3335
import 'channel_typing_indicator.dart';
@@ -38,7 +40,6 @@ import 'date_formatters.dart';
3840
import 'day_divider.dart';
3941
import 'dm_channel_labels.dart';
4042
import 'ephemeral_channel_display.dart';
41-
import 'manage_channel_sheet.dart';
4243
import 'members_sheet.dart';
4344
import 'message_actions.dart';
4445
import 'message_content.dart';
@@ -277,27 +278,25 @@ class ChannelDetailPage extends HookConsumerWidget {
277278
channel: resolvedChannel,
278279
currentPubkey: currentPubkey,
279280
),
280-
if (!resolvedChannel.isDm)
281-
IconButton(
282-
color: context.colors.primary,
283-
onPressed: () async {
284-
final shouldClose = await showModalBottomSheet<bool>(
285-
context: context,
286-
isScrollControlled: true,
287-
showDragHandle: true,
288-
constraints: BoxConstraints(
289-
maxWidth: 640,
290-
maxHeight: MediaQuery.sizeOf(context).height * 0.9,
291-
),
292-
builder: (_) => ManageChannelSheet(channel: resolvedChannel),
293-
);
294-
if (shouldClose == true && context.mounted) {
295-
Navigator.of(context).pop();
296-
}
297-
},
298-
tooltip: 'Manage channel',
299-
icon: const Icon(LucideIcons.ellipsisVertical, size: 22),
300-
),
281+
IconButton(
282+
color: context.colors.primary,
283+
onPressed: () async {
284+
final shouldClose = await showChannelActionsSheet(
285+
context: context,
286+
channel: resolvedChannel,
287+
isUnread: false,
288+
sectionId: ref
289+
.read(channelSectionsProvider)
290+
.store
291+
.assignments[resolvedChannel.id],
292+
);
293+
if (shouldClose == true && context.mounted) {
294+
Navigator.of(context).pop();
295+
}
296+
},
297+
tooltip: 'Channel actions',
298+
icon: const Icon(LucideIcons.ellipsisVertical, size: 22),
299+
),
301300
],
302301
),
303302
body: Stack(

‎mobile/lib/features/channels/channel_management_provider.dart‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,20 @@ List<List<String>> buildCreateChannelTags({
479479
];
480480
}
481481

482+
/// Builds the relay tags for setting the archived state of [channelId].
483+
List<List<String>> buildSetChannelArchivedTags(
484+
String channelId, {
485+
required bool archived,
486+
}) => [
487+
['h', channelId],
488+
['archived', archived.toString()],
489+
];
490+
491+
/// Builds the relay tags for deleting [channelId].
492+
List<List<String>> buildDeleteChannelTags(String channelId) => [
493+
['h', channelId],
494+
];
495+
482496
class ChannelActions {
483497
final Ref _ref;
484498
final RelaySessionNotifier _session;
@@ -584,6 +598,36 @@ class ChannelActions {
584598
await _refreshChannelState(channelId);
585599
}
586600

601+
/// Archives the channel and refreshes its cached state.
602+
Future<void> archiveChannel(String channelId) =>
603+
_setChannelArchived(channelId, archived: true);
604+
605+
/// Unarchives the channel and refreshes its cached state.
606+
Future<void> unarchiveChannel(String channelId) =>
607+
_setChannelArchived(channelId, archived: false);
608+
609+
Future<void> _setChannelArchived(
610+
String channelId, {
611+
required bool archived,
612+
}) async {
613+
await _signedEventRelay.submit(
614+
kind: 9002,
615+
content: '',
616+
tags: buildSetChannelArchivedTags(channelId, archived: archived),
617+
);
618+
await _refreshChannelState(channelId);
619+
}
620+
621+
/// Deletes the channel and refreshes its cached state.
622+
Future<void> deleteChannel(String channelId) async {
623+
await _signedEventRelay.submit(
624+
kind: 9008,
625+
content: '',
626+
tags: buildDeleteChannelTags(channelId),
627+
);
628+
await _refreshChannelState(channelId);
629+
}
630+
587631
Future<void> setCanvas({
588632
required String channelId,
589633
required String content,

‎mobile/lib/features/channels/channels_page.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import '../profile/user_cache_provider.dart';
2929
import '../pairing/pairing_page.dart';
3030
import '../pairing/pairing_provider.dart';
3131
import 'channel.dart';
32+
import 'channel_actions_sheet.dart';
3233
import 'channel_detail_page.dart';
3334
import 'channel_management_provider.dart';
3435
import 'dm_channel_labels.dart';

‎mobile/lib/features/channels/channels_page/channel_tile.dart‎

Lines changed: 5 additions & 205 deletions
Original file line numberDiff line numberDiff line change
@@ -118,212 +118,12 @@ class _ChannelTile extends ConsumerWidget {
118118
}
119119

120120
void _showChannelActions(BuildContext context, WidgetRef ref) {
121-
showModalBottomSheet<void>(
121+
showChannelActionsSheet(
122122
context: context,
123-
showDragHandle: true,
124-
builder: (sheetContext) {
125-
final sections = ref.read(channelSectionsProvider).store.sections
126-
..sort((a, b) => a.order.compareTo(b.order));
127-
final isStarred =
128-
ref
129-
.read(channelStarsProvider)
130-
.store
131-
.channels[channel.id]
132-
?.starred ==
133-
true;
134-
135-
return SafeArea(
136-
child: Padding(
137-
padding: const EdgeInsets.fromLTRB(
138-
Grid.gutter,
139-
0,
140-
Grid.gutter,
141-
Grid.xs,
142-
),
143-
child: Column(
144-
mainAxisSize: MainAxisSize.min,
145-
children: [
146-
ListTile(
147-
leading: Icon(
148-
isStarred ? LucideIcons.starOff : LucideIcons.star,
149-
),
150-
title: Text(isStarred ? 'Unstar channel' : 'Star channel'),
151-
onTap: () {
152-
Navigator.of(sheetContext).pop();
153-
if (isStarred) {
154-
ref
155-
.read(channelStarsProvider.notifier)
156-
.unstarChannel(channel.id);
157-
} else {
158-
ref
159-
.read(channelStarsProvider.notifier)
160-
.starChannel(channel.id);
161-
}
162-
},
163-
),
164-
ListTile(
165-
leading: const Icon(LucideIcons.folderInput),
166-
title: const Text('Move to section'),
167-
onTap: () async {
168-
Navigator.of(sheetContext).pop();
169-
await _showMoveSectionSheet(context, ref, sections);
170-
},
171-
),
172-
ListTile(
173-
leading: Icon(
174-
isMuted ? LucideIcons.bell : LucideIcons.bellOff,
175-
),
176-
title: Text(isMuted ? 'Unmute channel' : 'Mute channel'),
177-
onTap: () {
178-
Navigator.of(sheetContext).pop();
179-
if (isMuted) {
180-
ref
181-
.read(channelMutesProvider.notifier)
182-
.unmuteChannel(channel.id);
183-
} else {
184-
ref
185-
.read(channelMutesProvider.notifier)
186-
.muteChannel(channel.id);
187-
}
188-
},
189-
),
190-
ListTile(
191-
leading: Icon(
192-
isUnread ? LucideIcons.checkCheck : LucideIcons.circleDot,
193-
),
194-
title: Text(isUnread ? 'Mark as read' : 'Mark as unread'),
195-
onTap: () {
196-
Navigator.of(sheetContext).pop();
197-
final ts = dateTimeToUnixSeconds(channel.lastMessageAt);
198-
if (ts != null) {
199-
if (isUnread) {
200-
onMarkRead?.call();
201-
ref
202-
.read(readStateProvider.notifier)
203-
.markContextRead(
204-
channel.id,
205-
ts,
206-
clearForcedMessages: true,
207-
);
208-
ref
209-
.read(channelsProvider.notifier)
210-
.clearObservedUnreadCoveredByRead(channel.id, ts);
211-
} else {
212-
ref
213-
.read(readStateProvider.notifier)
214-
.markContextUnread(
215-
channel.id,
216-
channelId: channel.id,
217-
);
218-
}
219-
}
220-
},
221-
),
222-
],
223-
),
224-
),
225-
);
226-
},
227-
);
228-
}
229-
230-
Future<void> _showMoveSectionSheet(
231-
BuildContext context,
232-
WidgetRef ref,
233-
List<ChannelSection> sections,
234-
) async {
235-
await showModalBottomSheet<void>(
236-
context: context,
237-
showDragHandle: true,
238-
builder: (sheetContext) {
239-
return SafeArea(
240-
child: Padding(
241-
padding: const EdgeInsets.fromLTRB(
242-
Grid.gutter,
243-
0,
244-
Grid.gutter,
245-
Grid.xs,
246-
),
247-
child: Column(
248-
mainAxisSize: MainAxisSize.min,
249-
children: [
250-
for (final section in sections)
251-
ListTile(
252-
leading: Icon(
253-
LucideIcons.folder,
254-
color: sectionId == section.id
255-
? sheetContext.colors.primary
256-
: null,
257-
),
258-
title: Text(section.name),
259-
trailing: sectionId == section.id
260-
? Icon(
261-
LucideIcons.check,
262-
color: sheetContext.colors.primary,
263-
)
264-
: null,
265-
onTap: () {
266-
Navigator.of(sheetContext).pop();
267-
ref
268-
.read(channelSectionsProvider.notifier)
269-
.assignChannel(channel.id, section.id);
270-
},
271-
),
272-
ListTile(
273-
leading: const Icon(LucideIcons.folderPlus),
274-
title: const Text('New section…'),
275-
onTap: () async {
276-
Navigator.of(sheetContext).pop();
277-
if (!context.mounted) return;
278-
final name = await showDialog<String>(
279-
context: context,
280-
builder: (_) => const _SectionNameDialog(
281-
title: 'New Section',
282-
confirmLabel: 'Create',
283-
),
284-
);
285-
if (name != null && name.isNotEmpty) {
286-
ref
287-
.read(channelSectionsProvider.notifier)
288-
.createSection(name);
289-
// Assign after create — sections list has been mutated,
290-
// re-read to find the new section by name.
291-
final newSection = ref
292-
.read(channelSectionsProvider)
293-
.store
294-
.sections
295-
.lastWhere(
296-
(s) => s.name == name.trim(),
297-
orElse: () => const ChannelSection(
298-
id: '',
299-
name: '',
300-
order: -1,
301-
),
302-
);
303-
if (newSection.id.isNotEmpty) {
304-
ref
305-
.read(channelSectionsProvider.notifier)
306-
.assignChannel(channel.id, newSection.id);
307-
}
308-
}
309-
},
310-
),
311-
if (sectionId != null)
312-
ListTile(
313-
leading: const Icon(LucideIcons.folderMinus),
314-
title: const Text('Remove from section'),
315-
onTap: () {
316-
Navigator.of(sheetContext).pop();
317-
ref
318-
.read(channelSectionsProvider.notifier)
319-
.unassignChannel(channel.id);
320-
},
321-
),
322-
],
323-
),
324-
),
325-
);
326-
},
123+
channel: channel,
124+
isUnread: isUnread,
125+
onMarkRead: onMarkRead,
126+
sectionId: sectionId,
327127
);
328128
}
329129
}

0 commit comments

Comments
 (0)