From 4c4d561f30d4399c46c94b3f314dbcb9efb59f2c Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 20 Mar 2020 17:00:18 +0100 Subject: [PATCH] new_android reward --- package.json | 2 +- src/component/AppNavigator.js | 26 ++++++++++++++++++++++++++ src/component/fileItem/view.js | 4 +++- src/constants.js | 1 + src/page/splash/index.js | 1 + src/page/splash/view.js | 1 + yarn.lock | 4 ++-- 7 files changed, 35 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6e2bbb9..0338f00 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@expo/vector-icons": "^8.1.0", "gfycat-style-urls": "^1.0.3", "lbry-redux": "lbryio/lbry-redux#69ffd110dbf3633e5847f61f008751edec033017", - "lbryinc": "lbryio/lbryinc#021ac75d9aa2db488cfff8e9be320402f038f955", + "lbryinc": "lbryio/lbryinc#667024ebb7cb207609273174ca422cee47469270", "lodash": ">=4.17.11", "merge": ">=1.2.1", "moment": "^2.22.1", diff --git a/src/component/AppNavigator.js b/src/component/AppNavigator.js index 6dc355b..d003376 100644 --- a/src/component/AppNavigator.js +++ b/src/component/AppNavigator.js @@ -54,7 +54,9 @@ import { } from 'lbry-redux'; import { Lbryio, + rewards as REWARD_TYPES, doBlackListedOutpointsSubscribe, + doClaimRewardType, doFilteredOutpointsSubscribe, doGetSync, doUserCheckEmailVerified, @@ -372,6 +374,28 @@ class AppWithNavigationState extends React.Component { ); }; + checkNewAndroidReward = () => { + const { dispatch, doToast } = this.props; + const claimRewardCallback = err => { + if (err) { + // an error occurred, do not display anything + return; + } + // reward successfully claimed + NativeModules.UtilityModule.setNativeBooleanSetting(Constants.SETTING_NEW_ANDROID_REWARD_CLAIMED, true); + }; + + NativeModules.UtilityModule.getNativeBooleanSetting(Constants.SETTING_NEW_ANDROID_REWARD_CLAIMED, false).then( + rewardClaimed => { + if (!rewardClaimed) { + dispatch( + doClaimRewardType(REWARD_TYPES.TYPE_NEW_ANDROID, { notifyError: false, callback: claimRewardCallback }), + ); + } + }, + ); + }; + handleSdkReady = () => { const { dispatch } = this.props; dispatch(doSetSdkReady()); @@ -398,6 +422,8 @@ class AppWithNavigationState extends React.Component { } }); }); + + this.checkNewAndroidReward(); }; handleAccountUnlockFailed() { diff --git a/src/component/fileItem/view.js b/src/component/fileItem/view.js index 5de069b..c2066a5 100644 --- a/src/component/fileItem/view.js +++ b/src/component/fileItem/view.js @@ -70,7 +70,9 @@ class FileItem extends React.PureComponent { const outpointsToHide = !blackListedOutpoints ? filteredOutpoints : blackListedOutpoints.concat(filteredOutpoints); - shouldHide = outpointsToHide.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout); + shouldHide = outpointsToHide.some( + outpoint => outpoint && outpoint.txid === claim.txid && outpoint.nout === claim.nout, + ); } if (shouldHide) { // don't display blacklisted or filtered outpoints on the Your tags page diff --git a/src/constants.js b/src/constants.js index bd66bc7..e3ac8df 100644 --- a/src/constants.js +++ b/src/constants.js @@ -45,6 +45,7 @@ const Constants = { SETTING_REWARDS_NOT_INTERESTED: 'rewardsNotInterested', SETTING_DEVICE_WALLET_SYNCED: 'deviceWalletSynced', SETTING_DHT_ENABLED: 'dhtEnabled', + SETTING_NEW_ANDROID_REWARD_CLAIMED: 'newAndroidRewardClaimed', ACTION_SDK_READY: 'SDK_READY', diff --git a/src/page/splash/index.js b/src/page/splash/index.js index e9a3a3b..7e8e3b7 100644 --- a/src/page/splash/index.js +++ b/src/page/splash/index.js @@ -2,6 +2,7 @@ import { connect } from 'react-redux'; import { SETTINGS, doUpdateBlockHeight, doPopulateSharedUserState, doToast } from 'lbry-redux'; import { doAuthenticate, + doClaimRewardType, doInstallNewWithParams, doFetchMySubscriptions, doFetchRewardedContent, diff --git a/src/page/splash/view.js b/src/page/splash/view.js index 83c93f7..5ad5265 100644 --- a/src/page/splash/view.js +++ b/src/page/splash/view.js @@ -159,6 +159,7 @@ class SplashScreen extends React.PureComponent { this.getUserSettings(); }); }); + this.navigateToMain(); return; } diff --git a/yarn.lock b/yarn.lock index 11f51b7..7a7426d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4599,9 +4599,9 @@ lbry-redux@lbryio/lbry-redux#69ffd110dbf3633e5847f61f008751edec033017: reselect "^3.0.0" uuid "^3.3.2" -lbryinc@lbryio/lbryinc#021ac75d9aa2db488cfff8e9be320402f038f955: +lbryinc@lbryio/lbryinc#667024ebb7cb207609273174ca422cee47469270: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/021ac75d9aa2db488cfff8e9be320402f038f955" + resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/667024ebb7cb207609273174ca422cee47469270" dependencies: reselect "^3.0.0"