add knock support

Fixes #123
This commit is contained in:
Henry Hiles 2026-10-21 12:32:02 -04:00
commit 427e06be3e
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -40,4 +40,29 @@ extension JoinRoom on BuildContext {
return roomId;
}
/// Knocks on a room, success and errors in snackbars.
/// Returns the room's ID, or null if knocking failed.
Future<String?> knockRoom(
JoinRoomRequest request, {
required String name,
}) async {
final container = ProviderScope.containerOf(this);
final messenger = ScaffoldMessenger.of(this);
final roomId = await withProgressSnackbar(
"Knocking on $name...",
() =>
container.read(ClientController.provider.notifier).knockRoom(request),
);
if (roomId == null) return null;
messenger.showSnackBar(
.new(
content: Text("Knocked on $name. Wait for a moderator to let you in."),
),
);
return roomId;
}
}