1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-26 14:59:22 +00:00

Get call status from server

This commit is contained in:
Pierre HUBERT 2020-04-20 10:37:59 +02:00
parent 5eaf8d6b72
commit f227209e9b
3 changed files with 29 additions and 11 deletions

View File

@ -215,7 +215,12 @@ class ConversationsHelper {
following: map["following"] == 1, following: map["following"] == 1,
sawLastMessage: map["saw_last_message"] == 1, sawLastMessage: map["saw_last_message"] == 1,
members: List<int>.from(map["members"]), members: List<int>.from(map["members"]),
); callCapabilities: map["can_have_video_call"]
? CallCapabilities.VIDEO
: (map["can_have_call"]
? CallCapabilities.AUDIO
: CallCapabilities.NONE),
isHavingCall: map["has_call_now"]);
} }
/// Parse a list of messages given by the server /// Parse a list of messages given by the server

View File

@ -8,6 +8,8 @@ import 'package:meta/meta.dart';
/// ///
/// @author Pierre HUBERT /// @author Pierre HUBERT
enum CallCapabilities { NONE, AUDIO, VIDEO }
class Conversation extends CacheModel implements Comparable { class Conversation extends CacheModel implements Comparable {
final int ownerID; final int ownerID;
final int lastActive; final int lastActive;
@ -15,6 +17,8 @@ class Conversation extends CacheModel implements Comparable {
final bool following; final bool following;
final bool sawLastMessage; final bool sawLastMessage;
final List<int> members; final List<int> members;
final CallCapabilities callCapabilities;
final bool isHavingCall;
const Conversation({ const Conversation({
@required int id, @required int id,
@ -24,12 +28,16 @@ class Conversation extends CacheModel implements Comparable {
@required this.following, @required this.following,
@required this.sawLastMessage, @required this.sawLastMessage,
@required this.members, @required this.members,
this.callCapabilities = CallCapabilities.NONE,
this.isHavingCall = false,
}) : assert(id != null), }) : assert(id != null),
assert(ownerID != null), assert(ownerID != null),
assert(lastActive != null), assert(lastActive != null),
assert(following != null), assert(following != null),
assert(sawLastMessage != null), assert(sawLastMessage != null),
assert(members != null), assert(members != null),
assert(callCapabilities != null),
assert(isHavingCall != null),
super(id: id); super(id: id);
/// Check out whether a conversation has a fixed name or not /// Check out whether a conversation has a fixed name or not
@ -45,8 +53,12 @@ class Conversation extends CacheModel implements Comparable {
name = map[ConversationTableContract.C_NAME], name = map[ConversationTableContract.C_NAME],
following = map[ConversationTableContract.C_FOLLOWING] == 1, following = map[ConversationTableContract.C_FOLLOWING] == 1,
sawLastMessage = map[ConversationTableContract.C_SAW_LAST_MESSAGE] == 1, sawLastMessage = map[ConversationTableContract.C_SAW_LAST_MESSAGE] == 1,
members = listToIntList( members =
map[ConversationTableContract.C_MEMBERS].split(",")), listToIntList(map[ConversationTableContract.C_MEMBERS].split(",")),
// By default, we can not do any call
callCapabilities = CallCapabilities.NONE,
isHavingCall = false,
super.fromMap(map); super.fromMap(map);
@override @override

View File

@ -42,7 +42,8 @@ class _ConversationRouteState extends State<ConversationRoute> {
Future<void> _loadConversation() async { Future<void> _loadConversation() async {
setError(false); setError(false);
_conversation = await _conversationsHelper.getSingle(widget.conversationID); _conversation = await _conversationsHelper.getSingle(widget.conversationID,
force: true);
if (_conversation == null) return setError(true); if (_conversation == null) return setError(true);