In order for the lazy loading logic not to bleed into all corners
of the JS SDK, I moved some of the state copying between timelines
over to the RoomState and EventTimeLine class.
emit individual RoomState.members/newMember events
for each lazily loaded member as batch events are not a thing.
This makes updating the memberlist work
* fix displayname=undefined being disambiguated and strip Zero Width chars
* also strip diaritics and whitespace
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* check whether notif level is undefined, because `0` is falsey and it failed
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* improve number check for all m.room.power_levels related stuffs
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Pushrule evaluation needs the count of joined room members and
filtering the list for joined members takes a nontrivial amount
of time, but caching it is trivial, both code and memory wise.
We only need sentinel members for things like the 'sender' field
of events, so we previously created sentinels for everyone in the
room, but a large number of them were never used.
Instead, create them on-demand and cache them.
1. It's wrong because it doesn't consider the ban state
2. This should be caught by whether they have permission to send
the event in the first place rather than worrying about whether
it has notification permission or not
Rather than trying to be clever and keep ones whose power level isn't
affected, since they'll still have an associated power_levels event
that isn't the one actually in effect, which could be confusing.
When a ppower_levels event arrived, the current member objects were
being updated but the sentinel members were not, meaning that the
power levels of RoomMember objects associated with events had stale
power levels. This was causing power level based push rules to
be wrong.
Remove some we don't care about. Set some other ones we do care
about but don't currently adhere to to warn. Set the max warnings
threshold to the current number of warnings, so we don't introduce
more of them. Fix a bunch of legit lint errors and add exceptions
to various places in the test code that does funny things with
'this'.