Skip to content

Comments

Implement private read receipts and typing indicators#748

Open
Grafcube wants to merge 1 commit intocommetchat:mainfrom
Grafcube:private-rr
Open

Implement private read receipts and typing indicators#748
Grafcube wants to merge 1 commit intocommetchat:mainfrom
Grafcube:private-rr

Conversation

@Grafcube
Copy link

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:

image

Room overrides:

image

Includes options for room specific overrides.

Fixes commetchat#456
Fixes commetchat#645
Copy link
Contributor

@Airyzz Airyzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the implementations from the matrix sdk, client.setAccountDataPerRoom()

return _spaces.any((element) => element.identifier == identifier);
}

Future<Map<String, Object?>> getRoomAccountData(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use matrixRoom.roomAccountData[]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use more descriptive names than pti rpti

));
}

Future<void> onPRRChanged(bool? value) async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use more descriptive function names

import 'package:matrix/matrix.dart';
import 'package:tiamat/tiamat.dart' as tiamat;

class MatrixRoomChatPrivacySettings extends StatefulWidget {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all the logic for these settings is abstracted behind ReadReceiptComponent and TypingIndicatorComponent, this won't have to be a MatrixRoom specific settings page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Hide your read receipts Support hidden read receipts and hidden typing indicators

2 participants