mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Get the list of members of the call
This commit is contained in:
parent
04693cc163
commit
08c2ac32aa
@ -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>());
|
||||
}
|
||||
|
8
lib/lists/call_members_list.dart
Normal file
8
lib/lists/call_members_list.dart
Normal 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> {}
|
18
lib/models/call_member.dart
Normal file
18
lib/models/call_member.dart
Normal 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);
|
||||
}
|
@ -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() {
|
||||
if (_error)
|
||||
// Handle errors
|
||||
if (_error)
|
||||
return buildErrorCard(tr("Could not initialize call!"), actions: [
|
||||
MaterialButton(
|
||||
onPressed: () => _initCall(),
|
||||
|
Loading…
Reference in New Issue
Block a user