mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +01:00
chore: Do not create VoipPlugin on not supported platforms
This commit is contained in:
parent
bb4471b1a7
commit
0f167387ee
@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -167,10 +166,11 @@ class ChatController extends State<Chat> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
scrollController.addListener(_updateScrollController);
|
scrollController.addListener(_updateScrollController);
|
||||||
inputFocus.addListener(_inputFocusListener);
|
inputFocus.addListener(_inputFocusListener);
|
||||||
|
final voipPlugin = Matrix.of(context).voipPlugin;
|
||||||
|
|
||||||
if (!kIsWeb) {
|
if (voipPlugin != null) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((_) {
|
WidgetsBinding.instance?.addPostFrameCallback((_) {
|
||||||
CallKeepManager().setVoipPlugin(Matrix.of(context).voipPlugin);
|
CallKeepManager().setVoipPlugin(voipPlugin);
|
||||||
CallKeepManager().initialize().catchError((_) => true);
|
CallKeepManager().initialize().catchError((_) => true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -819,8 +819,6 @@ class ChatController extends State<Chat> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get webrtcIsSupported => PlatformInfos.isMobile;
|
|
||||||
|
|
||||||
int? findChildIndexCallback(Key key, Map<String, int> thisEventsKeyMap) {
|
int? findChildIndexCallback(Key key, Map<String, int> thisEventsKeyMap) {
|
||||||
// this method is called very often. As such, it has to be optimized for speed.
|
// this method is called very often. As such, it has to be optimized for speed.
|
||||||
if (key is! ValueKey) {
|
if (key is! ValueKey) {
|
||||||
@ -976,10 +974,10 @@ class ChatController extends State<Chat> {
|
|||||||
final success = await showFutureLoadingDialog(
|
final success = await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () =>
|
future: () =>
|
||||||
Matrix.of(context).voipPlugin.voip.requestTurnServerCredentials());
|
Matrix.of(context).voipPlugin!.voip.requestTurnServerCredentials());
|
||||||
if (success.result != null) {
|
if (success.result != null) {
|
||||||
final voipPlugin = Matrix.of(context).voipPlugin;
|
final voipPlugin = Matrix.of(context).voipPlugin;
|
||||||
await voipPlugin.voip.inviteToCall(room!.id, callType).catchError((e) {
|
await voipPlugin!.voip.inviteToCall(room!.id, callType).catchError((e) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text(e.toString())
|
SnackBar(content: Text(e.toString())
|
||||||
// Text(LocalizedExceptionExtension(context, e)),
|
// Text(LocalizedExceptionExtension(context, e)),
|
||||||
|
@ -113,7 +113,7 @@ class ChatView extends StatelessWidget {
|
|||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
if (controller.webrtcIsSupported)
|
if (Matrix.of(context).webrtcIsSupported)
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: controller.onPhoneButtonTap,
|
onPressed: controller.onPhoneButtonTap,
|
||||||
icon: const Icon(Icons.call_outlined),
|
icon: const Icon(Icons.call_outlined),
|
||||||
|
@ -83,7 +83,10 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||||||
return widget.clients[_activeClient];
|
return widget.clients[_activeClient];
|
||||||
}
|
}
|
||||||
|
|
||||||
VoipPlugin get voipPlugin => VoipPlugin(client: client, context: context);
|
bool get webrtcIsSupported => PlatformInfos.isMobile;
|
||||||
|
|
||||||
|
VoipPlugin? get voipPlugin =>
|
||||||
|
webrtcIsSupported ? VoipPlugin(client: client, context: context) : null;
|
||||||
|
|
||||||
bool get isMultiAccount => widget.clients.length > 1;
|
bool get isMultiAccount => widget.clients.length > 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user