mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
Merge branch 'krille/update-sdk' into 'main'
refactor: Update SDK and enable login with email and phone See merge request famedly/fluffychat!396
This commit is contained in:
commit
2d42da9e1f
@ -79,7 +79,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||
|
||||
File wallpaper;
|
||||
|
||||
void _initWithStore() async {
|
||||
void _initWithStore() {
|
||||
try {
|
||||
client.init();
|
||||
} catch (e, s) {
|
||||
@ -344,7 +344,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||
.where((e) =>
|
||||
e.type == EventUpdateType.timeline &&
|
||||
[EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
||||
.contains(e.eventType) &&
|
||||
.contains(e.content['type']) &&
|
||||
e.content['sender'] != client.userID)
|
||||
.listen(_showLocalNotification);
|
||||
});
|
||||
|
@ -46,7 +46,7 @@ class UrlLauncher {
|
||||
final response = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
matrix.client.requestRoomAliasInformations(roomIdOrAlias),
|
||||
matrix.client.requestRoomAliasInformation(roomIdOrAlias),
|
||||
);
|
||||
if (response.error != null) {
|
||||
return; // nothing to do, the alias doesn't exist
|
||||
|
@ -87,7 +87,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
||||
newAliases.add(canonicalAlias);
|
||||
final response = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.client.requestRoomAliasInformations(canonicalAlias),
|
||||
future: () => room.client.requestRoomAliasInformation(canonicalAlias),
|
||||
);
|
||||
if (response.error != null) {
|
||||
final success = await showFutureLoadingDialog(
|
||||
@ -327,8 +327,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
||||
// okay, we need to test if there are any emote state events other than the default one
|
||||
// if so, we need to be directed to a selection screen for which pack we want to look at
|
||||
// otherwise, we just open the normal one.
|
||||
if ((room.states
|
||||
.states['im.ponies.room_emotes'] ??
|
||||
if ((room.states['im.ponies.room_emotes'] ??
|
||||
<String, Event>{})
|
||||
.keys
|
||||
.any((String s) => s.isNotEmpty)) {
|
||||
|
@ -36,7 +36,6 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.login(
|
||||
type: AuthenticationTypes.token,
|
||||
userIdentifierType: null,
|
||||
token: token,
|
||||
initialDeviceDisplayName: PlatformInfos.clientName,
|
||||
),
|
||||
|
@ -42,8 +42,28 @@ class _LoginState extends State<Login> {
|
||||
|
||||
setState(() => loading = true);
|
||||
try {
|
||||
final username = usernameController.text;
|
||||
AuthenticationIdentifier identifier;
|
||||
if (username.isEmail) {
|
||||
identifier = AuthenticationThirdPartyIdentifier(
|
||||
medium: 'email',
|
||||
address: username,
|
||||
);
|
||||
} else if (username.isPhoneNumber) {
|
||||
identifier = AuthenticationThirdPartyIdentifier(
|
||||
medium: 'msisdn',
|
||||
address: username,
|
||||
);
|
||||
} else {
|
||||
identifier = AuthenticationUserIdentifier(user: username);
|
||||
}
|
||||
await matrix.client.login(
|
||||
user: usernameController.text,
|
||||
identifier: identifier,
|
||||
// To stay compatible with older server versions
|
||||
// ignore: deprecated_member_use
|
||||
user: identifier.type == AuthenticationIdentifierTypes.userId
|
||||
? username
|
||||
: null,
|
||||
password: passwordController.text,
|
||||
initialDeviceDisplayName: PlatformInfos.clientName);
|
||||
} on MatrixException catch (exception) {
|
||||
@ -255,3 +275,12 @@ class _LoginState extends State<Login> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension on String {
|
||||
static final RegExp _emailRegex = RegExp(
|
||||
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+");
|
||||
static final RegExp _phoneRegex =
|
||||
RegExp(r'^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$');
|
||||
bool get isEmail => _emailRegex.hasMatch(this);
|
||||
bool get isPhoneNumber => _phoneRegex.hasMatch(this);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class MultipleEmotesSettings extends StatelessWidget {
|
||||
stream: room.onUpdate.stream,
|
||||
builder: (context, snapshot) {
|
||||
final packs =
|
||||
room.states.states['im.ponies.room_emotes'] ?? <String, Event>{};
|
||||
room.states['im.ponies.room_emotes'] ?? <String, Event>{};
|
||||
if (!packs.containsKey('')) {
|
||||
packs[''] = null;
|
||||
}
|
||||
|
13
pubspec.lock
13
pubspec.lock
@ -197,6 +197,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.3"
|
||||
email_validator:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: email_validator
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.6"
|
||||
emoji_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -223,7 +230,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: "82f823f50e8dc96b60a5a1f288bb93bff84b1eb3"
|
||||
resolved-ref: fb0de1ce5993299b4f12d5a2adaa0324fe5d4f01
|
||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
@ -630,7 +637,7 @@ packages:
|
||||
name: matrix_api_lite
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.9"
|
||||
version: "0.2.0"
|
||||
matrix_file_e2ee:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -723,7 +730,7 @@ packages:
|
||||
name: olm
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
version: "1.3.0"
|
||||
open_file:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -84,6 +84,7 @@ dependencies:
|
||||
package_info: ^0.4.3+2
|
||||
flutter_app_lock: ^1.4.0+1
|
||||
flutter_screen_lock: ^1.2.6
|
||||
email_validator: ^1.0.6
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
Reference in New Issue
Block a user