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

Channel resumed parameter now has to be non-null #313

Merged
merged 3 commits into from Feb 8, 2022

Conversation

ikurek
Copy link
Contributor

@ikurek ikurek commented Feb 4, 2022

This is supposed to fix bug #297, the original fix was issued on #270 but I don't think the approach there was correct, so I changed a few things.

The issue was caused by this definition of Obj-C macro:

#define WRITE_VALUE(DICTIONARY, JSON_KEY, VALUE) { 
    if (VALUE) {
        [DICTIONARY setObject:VALUE forKey:JSON_KEY];
    } 
}

which is supposed to write JSON key only if VALUE parameter is not nil. By accident, if the parameter is not nil, but it happens to be 0 or any other falsey value, the key also isn't written 😆 I've updated the base method to only check for nil and also write false values.

The other error was with tenary operators and booleans. The expression:

[stateChange resumed]?@([stateChange resumed]):nil

evaluates to nil if resumed is nil or false, therefore false values were never written 😄

@ikurek ikurek self-assigned this Feb 4, 2022
@ikurek ikurek added the bug Something isn't working. It's clear that this does need to be fixed. label Feb 7, 2022
@QuintinWillison QuintinWillison merged commit 84e328c into main Feb 8, 2022
@QuintinWillison QuintinWillison deleted the fix/non-null-resume-parameter branch February 8, 2022 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

Successfully merging this pull request may close these issues.

ChannelStateChange property resumed should not be nullable
3 participants