add rate limit, add already joined
This commit is contained in:
parent
f780f450ee
commit
d2f1340f75
3 changed files with 17 additions and 0 deletions
|
|
@ -4086,6 +4086,7 @@
|
|||
}
|
||||
},
|
||||
"roomCapacityExplanation": "{roomType} capacity limits the number of non-admins allowed in a room.",
|
||||
"tooManyRequest": "Too many request, please try again later.",
|
||||
"@roomCapacityExplanation": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,13 @@ class ClassController extends BaseController {
|
|||
},
|
||||
body: jsonEncode({'access_code': classCode}),
|
||||
);
|
||||
if (knockResponse.statusCode == 429) {
|
||||
SpaceCodeUtil.messageSnack(
|
||||
context,
|
||||
L10n.of(context)!.tooManyRequest,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (knockResponse.statusCode != 200) {
|
||||
SpaceCodeUtil.messageSnack(
|
||||
context,
|
||||
|
|
@ -87,6 +94,14 @@ class ClassController extends BaseController {
|
|||
}
|
||||
final knockResult = jsonDecode(knockResponse.body);
|
||||
final foundClasses = List<String>.from(knockResult['rooms']);
|
||||
final alreadyJoined = List<String>.from(knockResult['already_joined']);
|
||||
if (alreadyJoined.isNotEmpty) {
|
||||
SpaceCodeUtil.messageSnack(
|
||||
context,
|
||||
L10n.of(context)!.alreadyInClass,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (foundClasses.isEmpty) {
|
||||
SpaceCodeUtil.messageSnack(
|
||||
context,
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ class SpaceCodeUtil {
|
|||
SnackBar(
|
||||
duration: const Duration(seconds: 10),
|
||||
content: Text(message),
|
||||
showCloseIcon: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue