@@ -50,11 +50,11 @@ class QUOTIENT_API RoomStateView
5050 template <Keyed_State_Event EvT>
5151 const EvT* get (const QString& stateKey = {}) const
5252 {
53- if ( const auto * evt = get ( EvT::TypeId, stateKey)) {
54- Q_ASSERT ( evt-> matrixType () == EvT::TypeId
55- && evt->stateKey () == stateKey);
56- return eventCast<const EvT>(evt);
57- }
53+ for ( auto typeId : EvT::MetaType. matrixIds )
54+ if ( const auto * evt = get (typeId, stateKey)) {
55+ Q_ASSERT (evt-> matrixType () == typeId && evt->stateKey () == stateKey);
56+ return eventCast<const EvT>(evt);
57+ }
5858 return nullptr ;
5959 }
6060
@@ -66,10 +66,11 @@ class QUOTIENT_API RoomStateView
6666 template <Keyless_State_Event EvT>
6767 const EvT* get () const
6868 {
69- if (const auto * evt = get (EvT::TypeId)) {
70- Q_ASSERT (evt->matrixType () == EvT::TypeId);
71- return eventCast<const EvT>(evt);
72- }
69+ for (auto typeId : EvT::MetaType.matrixIds )
70+ if (const auto *evt = get (typeId)) {
71+ Q_ASSERT (evt->matrixType () == typeId);
72+ return eventCast<const EvT>(evt);
73+ }
7374 return nullptr ;
7475 }
7576
@@ -80,20 +81,23 @@ class QUOTIENT_API RoomStateView
8081 template <Keyed_State_Event EvT>
8182 bool contains (const QString& stateKey = {}) const
8283 {
83- return contains (EvT::TypeId, stateKey);
84+ return std::ranges::any_of (EvT::MetaType.matrixIds , [this , &stateKey](event_type_t typeId) {
85+ return contains (typeId, stateKey);
86+ });
8487 }
8588
8689 template <Keyless_State_Event EvT>
8790 bool contains () const
8891 {
89- return contains (EvT::TypeId);
92+ return std::ranges::any_of (EvT::MetaType.matrixIds ,
93+ [this ](event_type_t typeId) { return contains (typeId); });
9094 }
9195
9296 template <Keyed_State_Event EvT>
9397 auto content (const QString& stateKey,
9498 typename EvT::content_type defaultValue = {}) const
9599 {
96- // EventBase <>::content is special in that it returns a const-ref,
100+ // EventTemplate <>::content for StateEvent is special in that it returns a const-ref,
97101 // and lift() inside queryOr() can't wrap that in a temporary optional.
98102 if (const auto evt = get<EvT>(stateKey))
99103 return evt->content ();
0 commit comments