move to new sdk
This commit is contained in:
parent
7e3d330a68
commit
6868f38c7c
26 changed files with 172 additions and 201 deletions
|
|
@ -46,9 +46,9 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
Widget build(BuildContext context) {
|
||||
notificationChangeSub ??= Matrix.of(context)
|
||||
.client
|
||||
.onUserEvent
|
||||
.onAccountData
|
||||
.stream
|
||||
.where((u) => u.type == 'account_data' && u.eventType == 'm.push_rules')
|
||||
.where((u) => u.type == 'm.push_rules')
|
||||
.listen(
|
||||
(u) => setState(() => null),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class PresenceDialog extends StatelessWidget {
|
|||
contentPadding: EdgeInsets.zero,
|
||||
leading: Avatar(avatarUrl, displayname),
|
||||
title: Text(displayname),
|
||||
subtitle: Text(presence.sender),
|
||||
subtitle: Text(presence.senderId),
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
@ -38,7 +38,7 @@ class PresenceDialog extends StatelessWidget {
|
|||
Text(
|
||||
presence.presence.toString().split('.').last,
|
||||
style: TextStyle(
|
||||
color: presence.currentlyActive == true
|
||||
color: presence.presence.currentlyActive == true
|
||||
? Colors.green
|
||||
: Theme.of(context).primaryColor,
|
||||
),
|
||||
|
|
@ -46,12 +46,12 @@ class PresenceDialog extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
if (presence.sender != Matrix.of(context).client.userID)
|
||||
if (presence.senderId != Matrix.of(context).client.userID)
|
||||
FlatButton(
|
||||
child: Text(L10n.of(context).sendAMessage),
|
||||
onPressed: () async {
|
||||
final roomId = await User(
|
||||
presence.sender,
|
||||
presence.senderId,
|
||||
room: Room(id: '', client: Matrix.of(context).client),
|
||||
).startDirectChat();
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:bubble/bubble.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/encryption.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:fluffychat/components/message_content.dart';
|
||||
import 'package:fluffychat/components/reply_content.dart';
|
||||
|
|
@ -98,11 +99,11 @@ class Message extends StatelessWidget {
|
|||
['m.in_reply_to']['event_id'],
|
||||
content: {'msgtype': 'm.text', 'body': '...'},
|
||||
senderId: event.senderId,
|
||||
typeKey: 'm.room.message',
|
||||
type: 'm.room.message',
|
||||
room: event.room,
|
||||
roomId: event.roomId,
|
||||
status: 1,
|
||||
time: DateTime.now(),
|
||||
originServerTs: DateTime.now(),
|
||||
);
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 4.0),
|
||||
|
|
@ -218,7 +219,7 @@ class _MetaRow extends StatelessWidget {
|
|||
),
|
||||
if (showDisplayname) SizedBox(width: 4),
|
||||
Text(
|
||||
event.time.localizedTime(context),
|
||||
event.originServerTs.localizedTime(context),
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontSize: 11,
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ class PresenceListItem extends StatelessWidget {
|
|||
static final Map<String, Profile> _presences = {};
|
||||
|
||||
Future<Profile> _requestProfile(BuildContext context) async {
|
||||
_presences[presence.sender] ??=
|
||||
await Matrix.of(context).client.getProfileFromUserId(presence.sender);
|
||||
return _presences[presence.sender];
|
||||
_presences[presence.senderId] ??=
|
||||
await Matrix.of(context).client.getProfileFromUserId(presence.senderId);
|
||||
return _presences[presence.senderId];
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -25,7 +25,7 @@ class PresenceListItem extends StatelessWidget {
|
|||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) return Container();
|
||||
Uri avatarUrl;
|
||||
var displayname = presence.sender.localpart;
|
||||
var displayname = presence.senderId.localpart;
|
||||
if (snapshot.hasData) {
|
||||
avatarUrl = snapshot.data.avatarUrl;
|
||||
displayname = snapshot.data.displayname;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/matrix_api.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
|
@ -6,15 +7,16 @@ import '../../l10n/l10n.dart';
|
|||
import '../../utils/app_route.dart';
|
||||
import '../../views/chat.dart';
|
||||
import '../avatar.dart';
|
||||
import '../matrix.dart';
|
||||
|
||||
class PublicRoomListItem extends StatelessWidget {
|
||||
final PublicRoomEntry publicRoomEntry;
|
||||
final PublicRoom publicRoomEntry;
|
||||
|
||||
const PublicRoomListItem(this.publicRoomEntry, {Key key}) : super(key: key);
|
||||
|
||||
void joinAction(BuildContext context) async {
|
||||
final success = await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(publicRoomEntry.join());
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.api.joinRoom(publicRoomEntry.roomId));
|
||||
if (success != false) {
|
||||
await Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:famedlysdk/encryption.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:fluffychat/utils/firebase_controller.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
|
@ -84,7 +85,7 @@ class MatrixState extends State<Matrix> {
|
|||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> getAuthByPassword(String password, String session) => {
|
||||
Map<String, dynamic> getAuthByPassword(String password, [String session]) => {
|
||||
'type': 'm.login.password',
|
||||
'identifier': {
|
||||
'type': 'm.id.user',
|
||||
|
|
@ -92,7 +93,7 @@ class MatrixState extends State<Matrix> {
|
|||
},
|
||||
'user': client.userID,
|
||||
'password': password,
|
||||
'session': session,
|
||||
if (session != null) 'session': session,
|
||||
};
|
||||
|
||||
StreamSubscription onRoomKeyRequestSub;
|
||||
|
|
@ -102,7 +103,7 @@ class MatrixState extends State<Matrix> {
|
|||
final event = Event.fromJson(
|
||||
eventUpdate.content, client.getRoomById(eventUpdate.roomID));
|
||||
if (DateTime.now().millisecondsSinceEpoch -
|
||||
event.time.millisecondsSinceEpoch >
|
||||
event.originServerTs.millisecondsSinceEpoch >
|
||||
1000 * 60 * 5) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -227,11 +228,12 @@ class _InheritedMatrix extends InheritedWidget {
|
|||
|
||||
@override
|
||||
bool updateShouldNotify(_InheritedMatrix old) {
|
||||
var update = old.data.client.accessToken != data.client.accessToken ||
|
||||
old.data.client.userID != data.client.userID ||
|
||||
old.data.client.deviceID != data.client.deviceID ||
|
||||
old.data.client.deviceName != data.client.deviceName ||
|
||||
old.data.client.homeserver != data.client.homeserver;
|
||||
var update =
|
||||
old.data.client.api.accessToken != data.client.api.accessToken ||
|
||||
old.data.client.userID != data.client.userID ||
|
||||
old.data.client.deviceID != data.client.deviceID ||
|
||||
old.data.client.deviceName != data.client.deviceName ||
|
||||
old.data.client.api.homeserver != data.client.api.homeserver;
|
||||
return update;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ class MessageContent extends StatelessWidget {
|
|||
break;
|
||||
default:
|
||||
return Text(
|
||||
L10n.of(context).userSentUnknownEvent(
|
||||
event.sender.calcDisplayname(), event.typeKey),
|
||||
L10n.of(context)
|
||||
.userSentUnknownEvent(event.sender.calcDisplayname(), event.type),
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue