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

Restore constructor props commits #4716

Closed
wants to merge 3 commits into from

Conversation

brunnre8
Copy link
Member

Val's PR apparently fixes the issue introduced by e31c95e in #4710

Meaning we can re-introduce the commits that were reverted after merging it.

However, I don't understand why the commit referenced above exposes the breakage that was apparently already there in the first place.
I'd appreciate it if someone could educate me / point my brain in the right direction

@brunnre8 brunnre8 added Meta: Internal This is an internal codebase change (testing, linting, etc.). Status: needs-review PR not yet reviewed by enough maintainers labels Mar 19, 2023
@xPaw
Copy link
Member

xPaw commented Mar 20, 2023

This is probably why:

var test = { a: 1, b: 2, c: 3 };

Object.assign(test, { b: undefined, c: null });

//test = {a: 1, b: undefined, c: null}

this.unread = 0;
this.highlight = 0;
this.users = new Map();
this.muted = false;
Copy link
Member

Choose a reason for hiding this comment

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

Since this is a class now, why don't we assign all of these as defaults on the class properties instead of setting them in the constructors?

this.muted = false;

if (attr) {
Object.assign(this, attr);
Copy link
Member

@xPaw xPaw Mar 20, 2023

Choose a reason for hiding this comment

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

I think a better fix would be make all of the parameters that chan creation uses explicit parameters of the constructor, such as constructor(name, type, key, muted) (and whatever else parameters can be set on creation.

Alternatively, it could be static helpers such as createNewQuery which returns an instance of new Chan that is set to type of query.

these comment also applies to the other models

@brunnre8
Copy link
Member Author

Let's go with the approach outlined by xpaw there and avoid similar issues for now if we can, or at least log them.

@brunnre8 brunnre8 closed this Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meta: Internal This is an internal codebase change (testing, linting, etc.). Status: needs-review PR not yet reviewed by enough maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants