Update SDK

This commit is contained in:
Sorunome 2020-08-16 12:54:43 +02:00
commit 32a1c3ca1c
31 changed files with 1394 additions and 261 deletions

View file

@ -33,7 +33,7 @@ class AppInfo extends StatelessWidget {
),
ListTile(
title: Text('Homeserver:'),
subtitle: Text(client.api.homeserver.toString()),
subtitle: Text(client.homeserver.toString()),
),
ListTile(
title: Text('Device name:'),

View file

@ -14,7 +14,7 @@ class AuthWebView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final url = Matrix.of(context).client.api.homeserver.toString() +
final url = Matrix.of(context).client.homeserver.toString() +
'/_matrix/client/r0/auth/$authType/fallback/web?session=$session';
if (kIsWeb) launch(url);
return Scaffold(

View file

@ -63,20 +63,18 @@ class _ChatDetailsState extends State<ChatDetails> {
var newAliases = List<String>.from(aliases);
newAliases.add(canonicalAlias);
final response = await SimpleDialogs(context).tryRequestWithLoadingDialog(
widget.room.client.api.requestRoomAliasInformations(canonicalAlias),
widget.room.client.requestRoomAliasInformations(canonicalAlias),
);
if (response == false) {
final success =
await SimpleDialogs(context).tryRequestWithLoadingDialog(
widget.room.client.api
.createRoomAlias(canonicalAlias, widget.room.id),
widget.room.client.createRoomAlias(canonicalAlias, widget.room.id),
);
if (success == false) return;
}
}
await SimpleDialogs(context).tryRequestWithLoadingDialog(
widget.room.client.api
.sendState(widget.room.id, 'm.room.canonical_alias', {
widget.room.client.sendState(widget.room.id, 'm.room.canonical_alias', {
'alias': '#$s:$domain',
}),
);

View file

@ -92,7 +92,7 @@ class _ChatListState extends State<ChatList> {
setState(() => loadingPublicRooms = true);
final newPublicRoomsResponse =
await SimpleDialogs(context).tryRequestWithErrorToast(
Matrix.of(context).client.api.searchPublicRooms(
Matrix.of(context).client.searchPublicRooms(
limit: 30,
includeAllNetworks: true,
genericSearchTerm: searchController.text,
@ -197,7 +197,7 @@ class _ChatListState extends State<ChatList> {
);
if (status?.isEmpty ?? true) return;
await SimpleDialogs(context).tryRequestWithLoadingDialog(
Matrix.of(context).client.api.sendPresence(
Matrix.of(context).client.sendPresence(
Matrix.of(context).client.userID, PresenceType.online,
statusMsg: status),
);

View file

@ -85,7 +85,7 @@ class _InvitationSelectionState extends State<InvitationSelection> {
setState(() => loading = true);
final matrix = Matrix.of(context);
final response = await SimpleDialogs(context).tryRequestWithErrorToast(
matrix.client.api.searchUser(text, limit: 10),
matrix.client.searchUser(text, limit: 10),
);
setState(() => loading = false);
if (response == false || (response?.results == null)) return;

View file

@ -45,7 +45,8 @@ class _LoginState extends State<Login> {
setState(() => loading = true);
try {
await matrix.client.login(
usernameController.text, passwordController.text,
user: usernameController.text,
password: passwordController.text,
initialDeviceDisplayName: matrix.widget.clientName);
} on MatrixException catch (exception) {
setState(() => passwordError = exception.errorMessage);
@ -91,7 +92,7 @@ class _LoginState extends State<Login> {
.getWellKnownInformationsByUserId(userId);
final newDomain = wellKnownInformations.mHomeserver?.baseUrl;
if ((newDomain?.isNotEmpty ?? false) &&
newDomain != Matrix.of(context).client.api.homeserver.toString()) {
newDomain != Matrix.of(context).client.homeserver.toString()) {
await SimpleDialogs(context).tryRequestWithErrorToast(
Matrix.of(context).client.checkServer(newDomain));
setState(() => usernameError = null);
@ -110,7 +111,6 @@ class _LoginState extends State<Login> {
title: Text(
L10n.of(context).logInTo(Matrix.of(context)
.client
.api
.homeserver
.toString()
.replaceFirst('https://', '')),

View file

@ -35,7 +35,7 @@ class _NewGroupState extends State<_NewGroup> {
final matrix = Matrix.of(context);
final String roomID =
await SimpleDialogs(context).tryRequestWithLoadingDialog(
matrix.client.api.createRoom(
matrix.client.createRoom(
preset: publicGroup
? api.CreateRoomPreset.public_chat
: api.CreateRoomPreset.private_chat,

View file

@ -90,7 +90,7 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
setState(() => loading = true);
final matrix = Matrix.of(context);
final response = await SimpleDialogs(context).tryRequestWithErrorToast(
matrix.client.api.searchUser(text, limit: 10),
matrix.client.searchUser(text, limit: 10),
);
setState(() => loading = false);
if (response == false || (response?.results?.isEmpty ?? true)) return;

View file

@ -77,7 +77,7 @@ class _SettingsState extends State<Settings> {
if (displayname == null) return;
final matrix = Matrix.of(context);
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
matrix.client.setDisplayname(displayname),
matrix.client.setDisplayname(matrix.client.userID, displayname),
);
if (success != false) {
setState(() {

View file

@ -28,7 +28,7 @@ class DevicesSettingsState extends State<DevicesSettings> {
List<Device> devices;
Future<bool> _loadUserDevices(BuildContext context) async {
if (devices != null) return true;
devices = await Matrix.of(context).client.api.requestDevices();
devices = await Matrix.of(context).client.requestDevices();
return true;
}
@ -49,7 +49,7 @@ class DevicesSettingsState extends State<DevicesSettings> {
if (password == null) return;
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
matrix.client.api.deleteDevices(deviceIds,
matrix.client.deleteDevices(deviceIds,
auth: matrix.getAuthByPassword(password)));
if (success != false) {
reload();

View file

@ -73,12 +73,11 @@ class _EmotesSettingsState extends State<EmotesSettings> {
debugPrint(content.toString());
if (widget.room != null) {
await SimpleDialogs(context).tryRequestWithLoadingDialog(
client.api.sendState(widget.room.id, 'im.ponies.room_emotes', content),
client.sendState(widget.room.id, 'im.ponies.room_emotes', content),
);
} else {
await SimpleDialogs(context).tryRequestWithLoadingDialog(
client.api
.setAccountData(client.userID, 'im.ponies.user_emotes', content),
client.setAccountData(client.userID, 'im.ponies.user_emotes', content),
);
}
}
@ -377,10 +376,7 @@ class _EmoteImagePickerState extends State<_EmoteImagePicker> {
final matrixFile = MatrixFile(bytes: file.bytes, name: file.path);
final uploadResp =
await SimpleDialogs(context).tryRequestWithLoadingDialog(
Matrix.of(context)
.client
.api
.upload(matrixFile.bytes, matrixFile.name),
Matrix.of(context).client.upload(matrixFile.bytes, matrixFile.name),
);
setState(() {
widget.controller.text = uploadResp;

View file

@ -49,7 +49,7 @@ class _SignUpState extends State<SignUp> {
usernameController.text.toLowerCase().replaceAll(' ', '-');
try {
await matrix.client.api.usernameAvailable(preferredUsername);
await matrix.client.usernameAvailable(preferredUsername);
} on MatrixException catch (exception) {
setState(() => usernameError = exception.errorMessage);
return setState(() => loading = false);
@ -75,7 +75,6 @@ class _SignUpState extends State<SignUp> {
title: Text(
Matrix.of(context)
.client
.api
.homeserver
.toString()
.replaceFirst('https://', ''),

View file

@ -92,7 +92,8 @@ class _SignUpPasswordState extends State<SignUpPassword> {
await matrix.client.onLoginStateChanged.stream
.firstWhere((l) => l == LoginState.logged);
try {
await matrix.client.setDisplayname(widget.displayname);
await matrix.client
.setDisplayname(matrix.client.userID, widget.displayname);
} catch (exception) {
BotToast.showText(text: L10n.of(context).couldNotSetDisplayname);
}