This is something I probably wouldn't have rushed nearly as much,
except I have a serious use-case coming up; specifically
```js
foo = document.querySelector('foo')?.bar;
```
in a class property.
`document.querySelector('foo') && document.querySelector('foo').bar`
is incredibly inefficient here, but TypeScript doesn't consider
`(document.querySelector('foo') || {}).bar` to be valid because `{}`
doesn't have the `.bar` property. Creating a temporary variable
would have been a huge mess because this was a class property
initializer.
In hindsight, `(document.querySelector('foo')! || {}).bar` would
probably have worked, but too late now.
[02:42:41] peach: name never starts with a rank symbol on initialization
[02:42:50] peach: and it never starts with a rank symbol in userdetails
[02:43:10] peach: so i think you can just delete the line i linked as well as L2467 and be fine
Clicking on a user with a very large trainercard (generally, a bot in
a lot of rooms) would often push the trainercard offscreen even if it
fit, or push the trainercard to unscrollable areas.
With this change, the trainercard will no longer go offscreen unless
it doesn't fit, and if it doesn't fit, it will always be scrollable.
This adds a new global button type (`cmd`). It works like `send`,
except it's processed for client commands, as if a user had typed it
into the commandline and pressed Enter.
This should make passing event handlers into Preact significantly less
common, and save a lot of duplicate code, and also save needing
`preventDefault` and `stopImmediatePropagation` everywhere.
`cmd`, `send`, and `joinRoom` combined should also allow buttons sent
from the server even more flexibility in what they can do.
Maybe at some point we'd even want a client `chat-commands` file.
Also:
- Support `/challenge [username]`
- Show an error when trying to challenge a chatroom
- Make the Main Menu scrollable
- Improve comment-documentation of PS.leftRoom etc
* Use SockJS' timeout config option
This sets timeouts on connections to 5 minutes, matching the server's
heartbeat interval to close sockets that shouldn't be open anymore.
* Update SockJS client to v1.4.0
This fixes an issue where SockJS would parse the entire HTTP response
received as JSON, not the response's body alone.
This adds support for a Challenge menu to the new Preact client.
- New: Support for "Controls", allowing Preact to render JSX at the
bottom of chat scrollback - intended for challenge menus and battle
controls in PS Mobile.
- New: <<pm-[userid]>> and <<challenge-[userid]>> links
- New: Support for client-side commands: /j, /chall, etc
- New: PMs have a user list
Actually challenging people isn't supported yet.
- Fixes bugs relating to multiple battles with background music going
simultaneously
- Battles now instantly progress to Team Preview; no need for
`.fastForwardTo(0)`
- Battles no longer play music before `|start|` or `|teampreview|`. This
makes it possible for roomgames not to have music.
We now use a modern technique of "figure out what the music state should
be from battle state, then move toward it", instead of "directly figure
out what music state changes result from what battle state changes".
This is the trick I learned from React, and it makes the code
significantly simpler and more maintainable.