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

fix(admob): improve defense logic to prevent multiple calls #4849

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

ifsnow
Copy link
Contributor

@ifsnow ifsnow commented Feb 2, 2021

Description

loaded: Whether the advert is loaded and can be shown.

If _loaded is changed to true when load() is called, the meaning of loaded getter becomes ambiguous.

If the goal is to prevent multiple calls, it would be better to use other variables for this.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

@vercel
Copy link

vercel bot commented Feb 2, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/invertase/react-native-firebase/hq6jrn4kz
✅ Preview: https://react-native-firebase-git-fork-ifsnow-fix-admob-loaded.invertase.vercel.app

@CLAassistant
Copy link

CLAassistant commented Feb 2, 2021

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Feb 2, 2021

Codecov Report

Merging #4849 (d8b2e37) into master (51edf96) will increase coverage by 0.41%.
The diff coverage is 86.67%.

@@            Coverage Diff             @@
##           master    #4849      +/-   ##
==========================================
+ Coverage   88.66%   89.06%   +0.41%     
==========================================
  Files         109      109              
  Lines        3712     3720       +8     
  Branches      347      347              
==========================================
+ Hits         3291     3313      +22     
+ Misses        379      365      -14     
  Partials       42       42              

Copy link
Collaborator

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

@mikehardy
Copy link
Collaborator

...I should add - thanks for the PR :-)

@mikehardy
Copy link
Collaborator

Hey @ifsnow - I had a comment on this PR, can you take a look?

@mikehardy mikehardy added Workflow: Waiting for User Response Blocked waiting for user response. plugin: admob Google AdMob labels Feb 4, 2021
@ifsnow
Copy link
Contributor Author

ifsnow commented Feb 4, 2021

@mikehardy Sorry for being late. If load() can be called again after receiving CLOSED event, it will need to be initialized here.

_handleAdEvent(event) {
    const { type, error, data } = event.body;

    ...

    if (type === AdEventType.CLOSED || type === RewardedAdEventType.CLOSED) {
      this._loaded = false;
      this._isLoadCalled = false; // <= here
    }

    ....
}

Let me know if this is what you said. I'll fix it right away.

@mikehardy
Copy link
Collaborator

Yes! I think that's the spot. I'm not sure if it could happen but it seems better to match the states precisely?

@ifsnow
Copy link
Contributor Author

ifsnow commented Feb 5, 2021

@mikehardy That's a good point. My commit was modified. Thanks!

@mikehardy
Copy link
Collaborator

Great! @ifsnow last thing left is to sign the CLA so we can merge the change? You can follow the details link on the github actions check to do it - I think it's this https://cla-assistant.io/invertase/react-native-firebase?pullRequest=4849

@mikehardy mikehardy added Blocked: Missing CLA Workflow: Pending Merge Waiting on CI or similar and removed Workflow: Waiting for User Response Blocked waiting for user response. labels Feb 5, 2021
Copy link
Collaborator

@mikehardy mikehardy 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!

@ifsnow
Copy link
Contributor Author

ifsnow commented Feb 5, 2021

@mikehardy Did it. Thanks

@mikehardy mikehardy merged commit 5a71ad7 into invertase:master Feb 5, 2021
@mikehardy
Copy link
Collaborator

v10.6.3 is newly published with this change 🚀

@ifsnow ifsnow deleted the fix/admob-loaded branch February 5, 2021 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: admob Google AdMob
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants