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

User model/fix subscription state predicates #1032

Merged
merged 2 commits into from
May 8, 2023

Conversation

rgomezp
Copy link
Contributor

@rgomezp rgomezp commented May 5, 2023

Fix Type Predicates

Summary

This update fixes issues with type predicates in the OneSignal code. It replaces type with optional chaining to prevent the function from throwing if the passed object is undefined/null. Additionally, it corrects the bug with the pushSubscriptionOSModel var type and updates it to be able to accept undefined values.

Overview

The update fixes type predicates in the OneSignal code to prevent the function from throwing if the passed object is undefined/null. This is achieved by using optional chaining since the type predicate accepts type. If the passed in obj is null or undefined, the predicate returns the corresponding boolean value.

Moreover, the pushSubscriptionOSModel var type has been corrected to be able to accept undefined values. This update fixes the issue with the type predicate checking the model data instead of the OSModel instance. Additionally, the pushSubscriptionOSModel var type is set here since we're not importing the OneSignal class.

Details

  • Replaced type with optional chaining to prevent the function from throwing if the passed object is undefined/null
  • Updated the pushSubscriptionOSModel var type to be able to accept undefined values
  • Corrected the issue with the type predicate checking the model data instead of the OSModel instance
  • pushSubscriptionOSModel var type set here since we're not importing the OneSignal class

These updates were made by @rgomezp.


This change is Reviewable

rgomezp added 2 commits May 5, 2023 15:24
Motivation: use optional chaining since the type predicate accepts <any> type. This prevents the function from throwing if the obj is undefined/null. If the passed in obj is null or undefined, the predicate should return the corresponding boolean value.
Motivation: 
* the type predicate checks the model data not the OSModel instance
* also, update the `pushSubscriptionOSModel` var type (can be undefined). We have to set it here because we're not importing the `OneSignal` class
@rgomezp rgomezp requested a review from jkasten2 May 5, 2023 23:34
@rgomezp rgomezp merged commit 500d8cd into user-model/v1 May 8, 2023
@rgomezp rgomezp deleted the user-model/fix-subscription-state-predicates branch May 8, 2023 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants