1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-10-23 06:53:23 +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

@ -208,14 +208,19 @@ class ConversationsHelper {
/// Turn an API entry into a [Conversation] object
Conversation _apiToConversation(Map<String, dynamic> map) {
return Conversation(
id: map["ID"],
ownerID: map["ID_owner"],
lastActive: map["last_active"],
name: map["name"] == false ? null : map["name"],
following: map["following"] == 1,
sawLastMessage: map["saw_last_message"] == 1,
members: List<int>.from(map["members"]),
);
id: map["ID"],
ownerID: map["ID_owner"],
lastActive: map["last_active"],
name: map["name"] == false ? null : map["name"],
following: map["following"] == 1,
sawLastMessage: map["saw_last_message"] == 1,
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

View File

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

View File

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