forked from Nexus/nexus
add dynamic hinting and latching for PMPs
This commit is contained in:
parent
225497030e
commit
c786344bf2
3 changed files with 120 additions and 37 deletions
|
|
@ -41,6 +41,11 @@ class const ProfileTrigger({
|
|||
final String suffix = "",
|
||||
final bool keepTrigger = false,
|
||||
}) with _$ProfileTrigger {
|
||||
bool matches(String text) =>
|
||||
text.length >= prefix.length + suffix.length &&
|
||||
text.startsWith(prefix) &&
|
||||
text.endsWith(suffix);
|
||||
|
||||
Map<String, Object?> toJson() => _$ProfileTriggerToJson(this);
|
||||
|
||||
factory ProfileTrigger.fromJson(Map<String, Object?> json) =>
|
||||
|
|
|
|||
20
lib/models/room_subprofiles.dart
Normal file
20
lib/models/room_subprofiles.dart
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import "package:collection/collection.dart";
|
||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/per_message_profiles.dart";
|
||||
|
||||
part "room_subprofiles.freezed.dart";
|
||||
|
||||
@freezed
|
||||
class const RoomSubprofiles({
|
||||
required final IList<StoredProfile> profiles,
|
||||
// Each trigger is tried in this order, as gomuks does when sending
|
||||
required final IList<StoredProfile> triggerOrder,
|
||||
final StoredProfile? current,
|
||||
}) with _$RoomSubprofiles {
|
||||
StoredProfile? triggeredBy(String text) => triggerOrder.firstWhereOrNull(
|
||||
(profile) =>
|
||||
profile.id.isNotEmpty &&
|
||||
profile.triggers.any((trigger) => trigger.matches(text)),
|
||||
);
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ class const Settings({
|
|||
final NameColor nameColor = .powerLevel,
|
||||
final ShowAndSend typingIndicators = .showAndSend,
|
||||
final bool subprofiles = false,
|
||||
final bool latchSubprofiles = false,
|
||||
|
||||
/// When not sending, read receipts are still sent privately, so that the
|
||||
/// user's other devices know what has been read.
|
||||
|
|
|
|||
Loading…
Reference in a new issue