mirror of
https://github.com/block/buzz.git
synced 2026-10-31 06:21:34 +00:00
Fix canvas editing membership gate
Signed-off-by: Fast Fizz <2df81cb51f05a9d5387ef24d7b9ecb8fcdfcd1c70ffabc67061c9596e1b5b1c4@buzz.block.builderlab.xyz> Co-authored-by: Fast Fizz <2df81cb51f05a9d5387ef24d7b9ecb8fcdfcd1c70ffabc67061c9596e1b5b1c4@buzz.block.builderlab.xyz
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user