Fast Fizz
2026-08-17 16:07:05 +01:00
parent c7c776e9b6
commit 19ede787df
2 changed files with 35 additions and 3 deletions

View File

@@ -51,7 +51,7 @@ class ManageChannelSheet extends HookConsumerWidget {
canonicalName.isNotEmpty &&
(nameDirty || descriptionDirty) &&
!isSavingDetails.value;
final canEditCanvas = !channel.isArchived;
final canEditCanvas = channel.isMember && !channel.isArchived;
Future<void> saveDetails() async {
if (!canSaveDetails) return;

View File

@@ -13,7 +13,11 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
const _currentPubkey = 'me';
Channel _channel({String type = 'stream', bool isArchived = false}) => Channel(
Channel _channel({
String type = 'stream',
bool isArchived = false,
bool isMember = true,
}) => Channel(
id: 'channel-id',
name: type == 'dm' ? 'Alice' : 'general',
channelType: type,
@@ -22,7 +26,7 @@ Channel _channel({String type = 'stream', bool isArchived = false}) => Channel(
createdBy: 'owner',
createdAt: DateTime(2025),
memberCount: 2,
isMember: true,
isMember: isMember,
archivedAt: isArchived ? DateTime(2025, 1, 2) : null,
);
@@ -59,6 +63,13 @@ Widget _modalApp({
overrides: [
currentPubkeyProvider.overrideWith((ref) => _currentPubkey),
channelMembersProvider(channel.id).overrideWith((ref) => loadMembers()),
channelCanvasProvider(channel.id).overrideWith(
(ref) async => const ChannelCanvas(
content: null,
updatedAt: null,
authorPubkey: null,
),
),
channelActionsProvider.overrideWith(createChannelActions),
],
child: MaterialApp(
@@ -351,6 +362,27 @@ void main() {
);
});
testWidgets('non-member cannot edit canvas from Manage channel', (
tester,
) async {
await tester.pumpWidget(
_modalApp(
channel: _channel(isMember: false),
loadMembers: () async => const [],
createChannelActions: (ref) => _FakeChannelActions(ref),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('Open actions'));
await tester.pumpAndSettle();
await tester.tap(find.text('Manage channel'));
await tester.pumpAndSettle();
final editCanvas = find.widgetWithText(FilledButton, 'Create canvas');
expect(editCanvas, findsOneWidget);
expect(tester.widget<FilledButton>(editCanvas).onPressed, isNull);
});
testWidgets('DM omits quick actions, then shows mute and copy rows', (
tester,
) async {