fix: Video calls

This commit is contained in:
Christian Pauly 2021-01-16 16:39:07 +01:00
commit 6a0c71ef4a
4 changed files with 25 additions and 29 deletions

View file

@ -5,9 +5,7 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:url_launcher/url_launcher.dart';
import '../app_config.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'matrix.dart';
@ -30,19 +28,6 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
super.dispose();
}
void startCallAction(BuildContext context) async {
final url =
'${AppConfig.jitsiInstance}${Uri.encodeComponent(widget.room.id.localpart)}';
final success = await showFutureLoadingDialog(
context: context,
future: () => widget.room.sendEvent({
'msgtype': Matrix.callNamespace,
'body': url,
}));
if (success.error != null) return;
await launch(url);
}
@override
Widget build(BuildContext context) {
notificationChangeSub ??= Matrix.of(context)
@ -110,9 +95,6 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
future: () =>
widget.room.setPushRuleState(PushRuleState.notify));
break;
case 'call':
startCallAction(context);
break;
case 'details':
if (AdaptivePageLayout.of(context).viewDataStack.length < 3) {
await AdaptivePageLayout.of(context)

View file

@ -320,14 +320,6 @@ class MatrixState extends State<Matrix> {
LoadingDialog.defaultBackLabel = L10n.of(context).close;
LoadingDialog.defaultOnError = (Object e) => e.toLocalizedString(context);
onJitsiCallSub ??= client.onEvent.stream
.where((e) =>
e.type == EventUpdateType.timeline &&
e.eventType == 'm.room.message' &&
e.content['content']['msgtype'] == Matrix.callNamespace &&
e.content['sender'] != client.userID)
.listen(onJitsiCall);
onRoomKeyRequestSub ??=
client.onRoomKeyRequest.stream.listen((RoomKeyRequest request) async {
final room = request.room;
@ -437,7 +429,7 @@ class MatrixState extends State<Matrix> {
void dispose() {
onRoomKeyRequestSub?.cancel();
onKeyVerificationRequestSub?.cancel();
onJitsiCallSub?.cancel();
onLoginStateChanged?.cancel();
onNotification?.cancel();
onFocusSub?.cancel();
onBlurSub?.cancel();

View file

@ -147,7 +147,7 @@ class MessageContent extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(Icons.phone_outlined),
Icon(Icons.phone_outlined, color: Colors.green),
SizedBox(width: 8),
Text(L10n.of(context).videoCall),
],