1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Handle call closed event

This commit is contained in:
2020-04-20 14:32:57 +02:00
parent 08d357fc72
commit 456df166b1
3 changed files with 23 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import 'package:comunic/lists/users_list.dart';
import 'package:comunic/models/call_config.dart';
import 'package:comunic/models/call_member.dart';
import 'package:comunic/models/conversation.dart';
import 'package:comunic/ui/routes/main_route.dart';
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
import 'package:comunic/ui/widgets/safe_state.dart';
import 'package:comunic/utils/account_utils.dart';
@ -88,12 +89,17 @@ class _CallScreenState extends SafeState<CallScreen> {
this.listen<UserLeftCallEvent>((e) {
if (e.callID == convID) _removeMember(e.userID);
});
this.listen<CallClosedEvent>((e) {
if (e.callID == convID) _leaveCall();
});
} catch (e, stack) {
print("Could not initialize call! $e\n$stack");
setState(() => _error = true);
}
}
// Do clean up operations when call screen is destroyed
void _endCall() async {
try {
// Leave the call
@ -103,6 +109,11 @@ class _CallScreenState extends SafeState<CallScreen> {
}
}
// Make us leave the call
void _leaveCall() {
MainController.of(context).popPage();
}
void _removeMember(int memberID) {
_membersList.removeUser(memberID);
setState(() {});