1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-26 04:48:51 +00:00

Get the list of members of the call

This commit is contained in:
Pierre HUBERT 2020-04-20 14:02:32 +02:00
parent 04693cc163
commit 08c2ac32aa
4 changed files with 45 additions and 1 deletions

View File

@ -1,5 +1,7 @@
import 'package:comunic/helpers/websocket_helper.dart';
import 'package:comunic/lists/call_members_list.dart';
import 'package:comunic/models/call_config.dart';
import 'package:comunic/models/call_member.dart';
/// Calls helper
///
@ -21,4 +23,15 @@ class CallsHelper {
iceServers: response["iceServers"].cast<String>(),
);
}
/// Get current call members
static Future<CallMembersList> getMembers(int callID) async =>
CallMembersList()
..addAll((await ws("calls/members", {"callID": callID}))
.map((f) => CallMember(
id: f["userID"],
status: f["ready"] ? MemberStatus.READY : MemberStatus.JOINED,
))
.toList()
.cast<CallMember>());
}

View File

@ -0,0 +1,8 @@
import 'package:comunic/lists/abstract_list.dart';
import 'package:comunic/models/call_member.dart';
/// Call members list
///
/// @author Pierre Hubert
class CallMembersList extends AbstractList<CallMember> {}

View File

@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
/// Single call member information
///
/// @author Pierre Hubert
enum MemberStatus { JOINED, READY }
class CallMember {
final int id;
final MemberStatus status;
const CallMember({
@required this.id,
@required this.status,
}) : assert(id != null),
assert(status != null);
}

View File

@ -1,5 +1,6 @@
import 'package:comunic/helpers/calls_helper.dart';
import 'package:comunic/helpers/conversations_helper.dart';
import 'package:comunic/lists/call_members_list.dart';
import 'package:comunic/models/call_config.dart';
import 'package:comunic/models/conversation.dart';
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
@ -33,6 +34,7 @@ class _CallScreenState extends SafeState<CallScreen> {
String _convName;
CallConfig _conf;
var _error = false;
CallMembersList _membersList;
@override
void initState() {
@ -63,6 +65,9 @@ class _CallScreenState extends SafeState<CallScreen> {
// Get call configuration
_conf = await CallsHelper.getConfig();
// Get current members of the call
_membersList = await CallsHelper.getMembers(convID);
} catch (e, stack) {
print("Could not initialize call! $e\n$stack");
setState(() => _error = true);
@ -92,8 +97,8 @@ class _CallScreenState extends SafeState<CallScreen> {
/// Build widget body
Widget _buildBody() {
// Handle errors
if (_error)
// Handle errors
return buildErrorCard(tr("Could not initialize call!"), actions: [
MaterialButton(
onPressed: () => _initCall(),