feat: Check markdown checkboxes in messages
This commit is contained in:
parent
7cc341ac91
commit
a2e5a940bd
5 changed files with 109 additions and 10 deletions
27
lib/utils/event_checkbox_extension.dart
Normal file
27
lib/utils/event_checkbox_extension.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import 'package:matrix/matrix.dart';
|
||||
|
||||
extension EventCheckboxRoomExtension on Room {
|
||||
static const String relationshipType = 'im.fluffychat.checkboxes';
|
||||
Future<String?> checkCheckbox(
|
||||
String eventId,
|
||||
int checkboxId, {
|
||||
String? txid,
|
||||
}) =>
|
||||
sendEvent(
|
||||
{
|
||||
'm.relates_to': {
|
||||
'rel_type': relationshipType,
|
||||
'event_id': eventId,
|
||||
'checkbox_id': checkboxId,
|
||||
},
|
||||
},
|
||||
type: EventTypes.Reaction,
|
||||
txid: txid,
|
||||
);
|
||||
}
|
||||
|
||||
extension EventCheckboxExtension on Event {
|
||||
int? get checkedCheckboxId => content
|
||||
.tryGetMap<String, Object?>('m.relates_to')
|
||||
?.tryGet<int>('checkbox_id');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue