Implement private read receipts and typing indicators#748
Implement private read receipts and typing indicators#748Grafcube wants to merge 1 commit intocommetchat:mainfrom
Conversation
Includes options for room specific overrides. Fixes commetchat#456 Fixes commetchat#645
Airyzz
left a comment
There was a problem hiding this comment.
Thanks for this! Looks like a great addition, but needs some changes in how its implemented.
The biggest issue to me is that there is a lot of repeated code around getting and parsing settings from account data. Instead, I'd suggest adding the following to ReadReceiptComponent and TypingIndicatorComponent
// ReadReceiptComponent
bool get usePublicReadReceipts;
bool usePublicReadReceiptsForRoom(Room room);
Future<void> setUsePublicReadReceipts(bool value);
Future<void> setUsePublicReadReceiptsForRoom(Room room, bool value);// TypingIndicatorComponent
bool get typingIndicatorsEnabled;
bool typingIndicatorsEnabledForRoom(Room room);
Future<void> setTypingIndicatorsEnabled(bool value);
Future<void> setTypingIndicatorsEnabledForRoom(Room room, bool value);And then just accessing these throughout the app instead.
Let me know if you have any questions!
| Future<void> setTypingStatus(bool status) async { | ||
| var pti = await client.matrixClient | ||
| .getAccountData( | ||
| client.matrixClient.userID!, MatrixClient.privateTypingIndicatorKey) |
There was a problem hiding this comment.
instead of matrixClient.getAccountData, access it through matrixClient.accountData[], as getAccountData will make a request to the server every time
| var rpti = await client | ||
| .getRoomAccountData(client.matrixClient.userID!, room.matrixRoom.id, | ||
| MatrixClient.privateTypingIndicatorKey) | ||
| .catchError((e) { |
There was a problem hiding this comment.
instead of matrixClient.getRoomAccountData, access it through matrixRoom.roomAccountData, as getRoomAccountData will make a request to the server every time
| return json as Map<String, Object?>; | ||
| } | ||
|
|
||
| Future<void> setRoomAccountData( |
There was a problem hiding this comment.
Use the implementations from the matrix sdk, client.setAccountDataPerRoom()
| return _spaces.any((element) => element.identifier == identifier); | ||
| } | ||
|
|
||
| Future<Map<String, Object?>> getRoomAccountData( |
There was a problem hiding this comment.
use matrixRoom.roomAccountData[]
There was a problem hiding this comment.
these changes seem to be due to using the wrong flutter version, please revert
| }); | ||
| var rdisabled = rpti["enabled"] is bool ? !(rpti["enabled"] as bool) : null; | ||
| var enabled = pti["enabled"] is bool ? pti["enabled"] as bool : false; | ||
|
|
There was a problem hiding this comment.
please use more descriptive names than pti rpti
| )); | ||
| } | ||
|
|
||
| Future<void> onPRRChanged(bool? value) async { |
There was a problem hiding this comment.
please use more descriptive function names
| import 'package:matrix/matrix.dart'; | ||
| import 'package:tiamat/tiamat.dart' as tiamat; | ||
|
|
||
| class MatrixRoomChatPrivacySettings extends StatefulWidget { |
There was a problem hiding this comment.
If all the logic for these settings is abstracted behind ReadReceiptComponent and TypingIndicatorComponent, this won't have to be a MatrixRoom specific settings page
Includes options for room specific overrides. The benefit of this implementation is that you can have different preferences for different accounts and those settings are restored on new devices.
I am very inexperienced with Flutter so there may be mistakes.
Fixes #456
Fixes #645
Screenshots
Global preferences:
Room overrides: