Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the logic of roomPredecessor into the RoomState class #3114

Merged
merged 3 commits into from
Feb 1, 2023

Conversation

andybalaam
Copy link
Contributor

@andybalaam andybalaam commented Jan 30, 2023

Part of element-hq/element-web#24323


This change is marked as an internal change (Task), so will not be included in the changelog.

@andybalaam andybalaam added the T-Task Tasks for the team like planning label Jan 30, 2023
@andybalaam andybalaam marked this pull request as ready for review January 30, 2023 16:04
@andybalaam andybalaam requested a review from a team as a code owner January 30, 2023 16:04
const predecessorEvent = this.getStateEvents(EventType.RoomPredecessor, "");
if (predecessorEvent) {
const roomId = predecessorEvent.getContent()["predecessor_room_id"];
if (roomId) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (roomId) {
if (typeof roomId === "string") {

For safety, since we can't trust the contents of events to match the types we want

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, fixed in 558392c

const roomId = predecessor["room_id"];
if (roomId) {
const eventId = predecessor["event_id"] || null;
return { roomId, eventId };
Copy link
Member

Choose a reason for hiding this comment

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

These two are also missing type checks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, fixed in 558392c

Copy link
Contributor

@germain-gg germain-gg left a comment

Choose a reason for hiding this comment

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

Looks good to me 💯

@andybalaam andybalaam merged commit fbd2c97 into develop Feb 1, 2023
@andybalaam andybalaam deleted the move-roomPredecessor-into-state branch February 1, 2023 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Task Tasks for the team like planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants