mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +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;
|
File wallpaper;
|
||||||
|
|
||||||
void _initWithStore() async {
|
void _initWithStore() {
|
||||||
try {
|
try {
|
||||||
client.init();
|
client.init();
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
@ -344,7 +344,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||||||
.where((e) =>
|
.where((e) =>
|
||||||
e.type == EventUpdateType.timeline &&
|
e.type == EventUpdateType.timeline &&
|
||||||
[EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
[EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
||||||
.contains(e.eventType) &&
|
.contains(e.content['type']) &&
|
||||||
e.content['sender'] != client.userID)
|
e.content['sender'] != client.userID)
|
||||||
.listen(_showLocalNotification);
|
.listen(_showLocalNotification);
|
||||||
});
|
});
|
||||||
|
@ -46,7 +46,7 @@ class UrlLauncher {
|
|||||||
final response = await showFutureLoadingDialog(
|
final response = await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () =>
|
future: () =>
|
||||||
matrix.client.requestRoomAliasInformations(roomIdOrAlias),
|
matrix.client.requestRoomAliasInformation(roomIdOrAlias),
|
||||||
);
|
);
|
||||||
if (response.error != null) {
|
if (response.error != null) {
|
||||||
return; // nothing to do, the alias doesn't exist
|
return; // nothing to do, the alias doesn't exist
|
||||||
|
@ -87,7 +87,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||||||
newAliases.add(canonicalAlias);
|
newAliases.add(canonicalAlias);
|
||||||
final response = await showFutureLoadingDialog(
|
final response = await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () => room.client.requestRoomAliasInformations(canonicalAlias),
|
future: () => room.client.requestRoomAliasInformation(canonicalAlias),
|
||||||
);
|
);
|
||||||
if (response.error != null) {
|
if (response.error != null) {
|
||||||
final success = await showFutureLoadingDialog(
|
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
|
// 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
|
// 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.
|
// otherwise, we just open the normal one.
|
||||||
if ((room.states
|
if ((room.states['im.ponies.room_emotes'] ??
|
||||||
.states['im.ponies.room_emotes'] ??
|
|
||||||
<String, Event>{})
|
<String, Event>{})
|
||||||
.keys
|
.keys
|
||||||
.any((String s) => s.isNotEmpty)) {
|
.any((String s) => s.isNotEmpty)) {
|
||||||
|
@ -36,7 +36,6 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
|||||||
context: context,
|
context: context,
|
||||||
future: () => Matrix.of(context).client.login(
|
future: () => Matrix.of(context).client.login(
|
||||||
type: AuthenticationTypes.token,
|
type: AuthenticationTypes.token,
|
||||||
userIdentifierType: null,
|
|
||||||
token: token,
|
token: token,
|
||||||
initialDeviceDisplayName: PlatformInfos.clientName,
|
initialDeviceDisplayName: PlatformInfos.clientName,
|
||||||
),
|
),
|
||||||
|
@ -42,8 +42,28 @@ class _LoginState extends State<Login> {
|
|||||||
|
|
||||||
setState(() => loading = true);
|
setState(() => loading = true);
|
||||||
try {
|
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(
|
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,
|
password: passwordController.text,
|
||||||
initialDeviceDisplayName: PlatformInfos.clientName);
|
initialDeviceDisplayName: PlatformInfos.clientName);
|
||||||
} on MatrixException catch (exception) {
|
} 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,
|
stream: room.onUpdate.stream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final packs =
|
final packs =
|
||||||
room.states.states['im.ponies.room_emotes'] ?? <String, Event>{};
|
room.states['im.ponies.room_emotes'] ?? <String, Event>{};
|
||||||
if (!packs.containsKey('')) {
|
if (!packs.containsKey('')) {
|
||||||
packs[''] = null;
|
packs[''] = null;
|
||||||
}
|
}
|
||||||
|
13
pubspec.lock
13
pubspec.lock
@ -197,6 +197,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.3"
|
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:
|
emoji_picker:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -223,7 +230,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: main
|
ref: main
|
||||||
resolved-ref: "82f823f50e8dc96b60a5a1f288bb93bff84b1eb3"
|
resolved-ref: fb0de1ce5993299b4f12d5a2adaa0324fe5d4f01
|
||||||
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"
|
||||||
@ -630,7 +637,7 @@ packages:
|
|||||||
name: matrix_api_lite
|
name: matrix_api_lite
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.9"
|
version: "0.2.0"
|
||||||
matrix_file_e2ee:
|
matrix_file_e2ee:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -723,7 +730,7 @@ packages:
|
|||||||
name: olm
|
name: olm
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.3.0"
|
||||||
open_file:
|
open_file:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -84,6 +84,7 @@ dependencies:
|
|||||||
package_info: ^0.4.3+2
|
package_info: ^0.4.3+2
|
||||||
flutter_app_lock: ^1.4.0+1
|
flutter_app_lock: ^1.4.0+1
|
||||||
flutter_screen_lock: ^1.2.6
|
flutter_screen_lock: ^1.2.6
|
||||||
|
email_validator: ^1.0.6
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
Reference in New Issue
Block a user