mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-17 14:30:40 +01:00
feat: Get jitsi instance from wellknown
This commit is contained in:
parent
aa5ce5610f
commit
bd24387212
@ -380,8 +380,9 @@ class MatrixState extends State<Matrix> {
|
|||||||
wallpaper = file;
|
wallpaper = file;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
store.getItem(SettingKeys.fontSizeFactor).then((value) => AppConfig
|
store.getItem(SettingKeys.fontSizeFactor).then((value) =>
|
||||||
.fontSizeFactor = double.tryParse(value) ?? AppConfig.fontSizeFactor);
|
AppConfig.fontSizeFactor =
|
||||||
|
double.tryParse(value ?? '') ?? AppConfig.fontSizeFactor);
|
||||||
store
|
store
|
||||||
.getItemBool(SettingKeys.renderHtml, AppConfig.renderHtml)
|
.getItemBool(SettingKeys.renderHtml, AppConfig.renderHtml)
|
||||||
.then((value) => AppConfig.renderHtml = value);
|
.then((value) => AppConfig.renderHtml = value);
|
||||||
|
@ -18,6 +18,22 @@
|
|||||||
"username": {}
|
"username": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"badServerVersionsException": "The homeserver supports the Spec versions:\n{serverVersions}\nBut this app supports only {supportedVersions}",
|
||||||
|
"@badServerVersionsException": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {
|
||||||
|
"serverVersions": {},
|
||||||
|
"supportedVersions": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"badServerLoginTypesException": "The homeserver supports the login types:\n{serverVersions}\nBut this app supports only:\n{supportedVersions}",
|
||||||
|
"@badServerLoginTypesException": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {
|
||||||
|
"serverVersions": {},
|
||||||
|
"supportedVersions": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
"account": "Account",
|
"account": "Account",
|
||||||
"@account": {
|
"@account": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
@ -14,7 +16,35 @@ extension LocalizedExceptionExtension on Object {
|
|||||||
return (this as MatrixException).errorMessage;
|
return (this as MatrixException).errorMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this is MatrixConnectionException) {
|
if (this is BadServerVersionsException) {
|
||||||
|
final serverVersions = (this as BadServerVersionsException)
|
||||||
|
.serverVersions
|
||||||
|
.toString()
|
||||||
|
.replaceAll('{', '"')
|
||||||
|
.replaceAll('}', '"');
|
||||||
|
final supportedVersions = (this as BadServerVersionsException)
|
||||||
|
.supportedVersions
|
||||||
|
.toString()
|
||||||
|
.replaceAll('{', '"')
|
||||||
|
.replaceAll('}', '"');
|
||||||
|
return L10n.of(context)
|
||||||
|
.badServerVersionsException(serverVersions, supportedVersions);
|
||||||
|
}
|
||||||
|
if (this is BadServerLoginTypesException) {
|
||||||
|
final serverVersions = (this as BadServerLoginTypesException)
|
||||||
|
.serverLoginTypes
|
||||||
|
.toString()
|
||||||
|
.replaceAll('{', '"')
|
||||||
|
.replaceAll('}', '"');
|
||||||
|
final supportedVersions = (this as BadServerLoginTypesException)
|
||||||
|
.supportedLoginTypes
|
||||||
|
.toString()
|
||||||
|
.replaceAll('{', '"')
|
||||||
|
.replaceAll('}', '"');
|
||||||
|
return L10n.of(context)
|
||||||
|
.badServerLoginTypesException(serverVersions, supportedVersions);
|
||||||
|
}
|
||||||
|
if (this is MatrixConnectionException || this is SocketException) {
|
||||||
L10n.of(context).noConnectionToTheServer;
|
L10n.of(context).noConnectionToTheServer;
|
||||||
}
|
}
|
||||||
Logs().w('Something went wrong: ', this);
|
Logs().w('Something went wrong: ', this);
|
||||||
|
@ -6,6 +6,7 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||||||
import 'package:fluffychat/components/default_app_bar_search_field.dart';
|
import 'package:fluffychat/components/default_app_bar_search_field.dart';
|
||||||
import 'package:fluffychat/components/matrix.dart';
|
import 'package:fluffychat/components/matrix.dart';
|
||||||
import 'package:fluffychat/app_config.dart';
|
import 'package:fluffychat/app_config.dart';
|
||||||
|
import 'package:fluffychat/config/setting_keys.dart';
|
||||||
import 'package:fluffychat/utils/platform_infos.dart';
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
import 'package:flushbar/flushbar_helper.dart';
|
import 'package:flushbar/flushbar_helper.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@ -78,7 +79,23 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setState(() => _isLoading = true);
|
setState(() => _isLoading = true);
|
||||||
await Matrix.of(context).client.checkHomeserver(homeserver);
|
final wellKnown =
|
||||||
|
await Matrix.of(context).client.checkHomeserver(homeserver);
|
||||||
|
|
||||||
|
var jitsi = wellKnown?.content
|
||||||
|
?.tryGet<Map<String, dynamic>>('im.vector.riot.jitsi')
|
||||||
|
?.tryGet<String>('preferredDomain');
|
||||||
|
if (jitsi != null) {
|
||||||
|
if (!jitsi.endsWith('/')) {
|
||||||
|
jitsi += '/';
|
||||||
|
}
|
||||||
|
Logs().v('Found custom jitsi instance $jitsi');
|
||||||
|
await Matrix.of(context)
|
||||||
|
.store
|
||||||
|
.setItem(SettingKeys.jitsiInstance, jitsi);
|
||||||
|
AppConfig.jitsiInstance = jitsi;
|
||||||
|
}
|
||||||
|
|
||||||
final loginTypes = await Matrix.of(context).client.requestLoginTypes();
|
final loginTypes = await Matrix.of(context).client.requestLoginTypes();
|
||||||
if (loginTypes.flows
|
if (loginTypes.flows
|
||||||
.any((flow) => flow.type == AuthenticationTypes.password)) {
|
.any((flow) => flow.type == AuthenticationTypes.password)) {
|
||||||
@ -92,9 +109,6 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
|||||||
await launch(
|
await launch(
|
||||||
'${Matrix.of(context).client.homeserver?.toString()}/_matrix/client/r0/login/sso/redirect?redirectUrl=$redirectUrl');
|
'${Matrix.of(context).client.homeserver?.toString()}/_matrix/client/r0/login/sso/redirect?redirectUrl=$redirectUrl');
|
||||||
}
|
}
|
||||||
} on String catch (e) {
|
|
||||||
// ignore: unawaited_futures
|
|
||||||
FlushbarHelper.createError(message: e).show(context);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore: unawaited_futures
|
// ignore: unawaited_futures
|
||||||
FlushbarHelper.createError(
|
FlushbarHelper.createError(
|
||||||
|
@ -223,7 +223,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: main
|
ref: main
|
||||||
resolved-ref: "9faf07e31ae825147c2b295517f04233e9342e25"
|
resolved-ref: fc8563849a4706ecef7c37fdd7d4fbb93757ec9b
|
||||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user