move to new sdk

This commit is contained in:
Sorunome 2020-06-10 08:07:01 +00:00 committed by Christian Pauly
commit 6868f38c7c
26 changed files with 172 additions and 201 deletions

View file

@ -3,7 +3,7 @@ import 'package:famedlysdk/famedlysdk.dart';
extension ClientPresenceExtension on Client {
List<Presence> get statusList {
final statusList = presences.values.toList().reversed.toList();
statusList.removeWhere((p) => p.statusMsg?.isEmpty ?? true);
statusList.removeWhere((p) => p.presence.statusMsg?.isEmpty ?? true);
statusList.reversed.toList();
return statusList;
}

View file

@ -42,7 +42,7 @@ abstract class FirebaseController {
);
return;
}
final pushers = await client.getPushers();
final pushers = await client.api.requestPushers();
final currentPushers = pushers.where((pusher) => pusher.pushkey == token);
if (currentPushers.length == 1 &&
currentPushers.first.kind == 'http' &&
@ -50,35 +50,35 @@ abstract class FirebaseController {
currentPushers.first.appDisplayName == clientName &&
currentPushers.first.deviceDisplayName == client.deviceName &&
currentPushers.first.lang == 'en' &&
currentPushers.first.data.url == GATEWAY_URL &&
currentPushers.first.data.url.toString() == GATEWAY_URL &&
currentPushers.first.data.format == PUSHER_FORMAT) {
debugPrint('[Push] Pusher already set');
} else {
if (currentPushers.isNotEmpty) {
for (final currentPusher in currentPushers) {
await client.setPushers(
token,
'null',
currentPusher.appId,
currentPusher.appDisplayName,
currentPusher.deviceDisplayName,
currentPusher.lang,
currentPusher.data.url,
currentPusher.pushkey = token;
currentPusher.kind = 'null';
await client.api.setPusher(
currentPusher,
append: true,
);
debugPrint('[Push] Remove legacy pusher for this device');
}
}
await client.setPushers(
token,
'http',
APP_ID,
clientName,
client.deviceName,
'en',
GATEWAY_URL,
await client.api.setPusher(
Pusher(
token,
APP_ID,
clientName,
client.deviceName,
'en',
PusherData(
url: Uri.parse(GATEWAY_URL),
format: PUSHER_FORMAT,
),
kind: 'http',
),
append: false,
format: PUSHER_FORMAT,
);
}
@ -224,7 +224,7 @@ abstract class FirebaseController {
messages: [
Message(
body,
event.time,
event.originServerTs,
person,
)
],

View file

@ -5,9 +5,11 @@ import 'date_time_extension.dart';
extension PresenceExtension on Presence {
String getLocalizedStatusMessage(BuildContext context) {
if (statusMsg?.isNotEmpty ?? false) {
return statusMsg;
if (presence.statusMsg?.isNotEmpty ?? false) {
return presence.statusMsg;
}
return L10n.of(context).lastActiveAgo(time.localizedTimeShort(context));
return L10n.of(context).lastActiveAgo(
DateTime.fromMillisecondsSinceEpoch(presence.lastActiveAgo)
.localizedTimeShort(context));
}
}

View file

@ -10,11 +10,13 @@ extension RoomStatusExtension on Room {
String getLocalizedStatus(BuildContext context) {
if (isDirectChat) {
if (directChatPresence != null) {
if (directChatPresence.currentlyActive == true) {
if (directChatPresence.presence.currentlyActive == true) {
return L10n.of(context).currentlyActive;
}
return L10n.of(context)
.lastActiveAgo(directChatPresence.time.localizedTimeShort(context));
return L10n.of(context).lastActiveAgo(
DateTime.fromMillisecondsSinceEpoch(
directChatPresence.presence.lastActiveAgo)
.localizedTimeShort(context));
}
return L10n.of(context).lastSeenLongTimeAgo;
}

View file

@ -23,7 +23,7 @@ class UrlLauncher {
final identifier = url.replaceAll('https://matrix.to/#/', '');
if (identifier.substring(0, 1) == '#') {
final response = await SimpleDialogs(context).tryRequestWithLoadingDialog(
matrix.client.joinRoomById(
matrix.client.api.joinRoom(
Uri.encodeComponent(identifier),
),
);