Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion play.pokemonshowdown.com/src/panel-popups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ class UserOptionsPanel extends PSRoomPanel {
data?: Record<string, string>,
};
getTargets() {
const [, targetUser, targetRoomid] = this.props.room.id.split('-');
const [, targetUser, ...rest] = this.props.room.id.split('-');
const targetRoomid = rest.join('-');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, isn't there Utils.splitFirst for this?

Image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [, targetUser, ...rest] = this.props.room.id.split('-');
const targetRoomid = rest.join('-');
const [, targetUser, targetRoomid] = PSUtils.splitFirst(this.props.room.id, '-', 2);

let targetRoom = (PS.rooms[targetRoomid] || null) as ChatRoom | null;
if (targetRoom?.type !== 'chat') targetRoom = targetRoom?.getParent() as ChatRoom;
if (targetRoom?.type !== 'chat') targetRoom = targetRoom?.getParent() as ChatRoom;
Expand Down