From 54906cb768bf88c95e8fc446dfdcf2ccf80e2650 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Thu, 19 Mar 2020 08:55:45 +0100 Subject: [PATCH] add flag for dispatching doInstallNew from doAuthenticate (#87) * add doInstallNewWithParams action * return dispatch for doInstallNewWithParams --- dist/bundle.es.js | 26 ++++++++++++++++++++++++-- dist/bundle.js | 28 +++++++++++++++++++++++++++- src/index.js | 1 + src/redux/actions/user.js | 31 +++++++++++++++++++++++++++++-- 4 files changed, 81 insertions(+), 5 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index a844ac2..742f4fc 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1298,9 +1298,27 @@ function doInstallNew(appVersion, os = null, firebaseToken = null, callbackForUs } }); }); +} +function doInstallNewWithParams(appVersion, installationId, nodeId, lbrynetVersion, os, platform, firebaseToken = null) { + return dispatch => { + const payload = { + app_version: appVersion + }; + + if (firebaseToken) { + payload.firebase_token = firebaseToken; + } + + payload.app_id = installationId; + payload.node_id = nodeId; + payload.daemon_version = lbrynetVersion; + payload.operating_system = os; + payload.platform = platform; + Lbryio.call('install', 'new', payload); + }; } // TODO: Call doInstallNew separately so we don't have to pass appVersion and os_system params? -function doAuthenticate(appVersion, os = null, firebaseToken = null, shareUsageData = true, callbackForUsersWhoAreSharingData) { +function doAuthenticate(appVersion, os = null, firebaseToken = null, shareUsageData = true, callbackForUsersWhoAreSharingData, callInstall = true) { return dispatch => { dispatch({ type: AUTHENTICATION_STARTED @@ -1318,7 +1336,10 @@ function doAuthenticate(appVersion, os = null, firebaseToken = null, shareUsageD if (shareUsageData) { dispatch(doRewardList()); dispatch(doFetchInviteStatus()); - doInstallNew(appVersion, os, firebaseToken, callbackForUsersWhoAreSharingData); + + if (callInstall) { + doInstallNew(appVersion, os, firebaseToken, callbackForUsersWhoAreSharingData); + } } }); }).catch(error => { @@ -3659,6 +3680,7 @@ exports.doFilteredOutpointsSubscribe = doFilteredOutpointsSubscribe; exports.doGenerateAuthToken = doGenerateAuthToken; exports.doGetSync = doGetSync; exports.doInstallNew = doInstallNew; +exports.doInstallNewWithParams = doInstallNewWithParams; exports.doRemoveUnreadSubscription = doRemoveUnreadSubscription; exports.doRemoveUnreadSubscriptions = doRemoveUnreadSubscriptions; exports.doResetSync = doResetSync; diff --git a/dist/bundle.js b/dist/bundle.js index 8614884..6032e2f 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -173,6 +173,8 @@ __webpack_require__.r(__webpack_exports__); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doInstallNew", function() { return redux_actions_user__WEBPACK_IMPORTED_MODULE_11__["doInstallNew"]; }); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doInstallNewWithParams", function() { return redux_actions_user__WEBPACK_IMPORTED_MODULE_11__["doInstallNewWithParams"]; }); + /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doAuthenticate", function() { return redux_actions_user__WEBPACK_IMPORTED_MODULE_11__["doAuthenticate"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "doUserFetch", function() { return redux_actions_user__WEBPACK_IMPORTED_MODULE_11__["doUserFetch"]; }); @@ -4827,6 +4829,7 @@ var selectYouTubeImportVideosComplete = Object(reselect__WEBPACK_IMPORTED_MODULE __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doFetchInviteStatus", function() { return doFetchInviteStatus; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doInstallNew", function() { return doInstallNew; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doInstallNewWithParams", function() { return doInstallNewWithParams; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doAuthenticate", function() { return doAuthenticate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doUserFetch", function() { return doUserFetch; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doUserCheckEmailVerified", function() { return doUserCheckEmailVerified; }); @@ -4927,6 +4930,25 @@ function doInstallNew(appVersion) { } }); }); +} +function doInstallNewWithParams(appVersion, installationId, nodeId, lbrynetVersion, os, platform) { + var firebaseToken = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; + return function (dispatch) { + var payload = { + app_version: appVersion + }; + + if (firebaseToken) { + payload.firebase_token = firebaseToken; + } + + payload.app_id = installationId; + payload.node_id = nodeId; + payload.daemon_version = lbrynetVersion; + payload.operating_system = os; + payload.platform = platform; + lbryio__WEBPACK_IMPORTED_MODULE_5__["default"].call('install', 'new', payload); + }; } // TODO: Call doInstallNew separately so we don't have to pass appVersion and os_system params? function doAuthenticate(appVersion) { @@ -4934,6 +4956,7 @@ function doAuthenticate(appVersion) { var firebaseToken = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; var shareUsageData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; var callbackForUsersWhoAreSharingData = arguments.length > 4 ? arguments[4] : undefined; + var callInstall = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; return function (dispatch) { dispatch({ type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["AUTHENTICATION_STARTED"] @@ -4951,7 +4974,10 @@ function doAuthenticate(appVersion) { if (shareUsageData) { dispatch(Object(redux_actions_rewards__WEBPACK_IMPORTED_MODULE_2__["doRewardList"])()); dispatch(doFetchInviteStatus()); - doInstallNew(appVersion, os, firebaseToken, callbackForUsersWhoAreSharingData); + + if (callInstall) { + doInstallNew(appVersion, os, firebaseToken, callbackForUsersWhoAreSharingData); + } } }); })["catch"](function (error) { diff --git a/src/index.js b/src/index.js index 4b65f57..763d63c 100644 --- a/src/index.js +++ b/src/index.js @@ -47,6 +47,7 @@ export { export { doFetchInviteStatus, doInstallNew, + doInstallNewWithParams, doAuthenticate, doUserFetch, doUserEmailNew, diff --git a/src/redux/actions/user.js b/src/redux/actions/user.js index 0cb18e7..7d17ae2 100644 --- a/src/redux/actions/user.js +++ b/src/redux/actions/user.js @@ -72,13 +72,38 @@ export function doInstallNew( }); } +export function doInstallNewWithParams( + appVersion, + installationId, + nodeId, + lbrynetVersion, + os, + platform, + firebaseToken = null +) { + return dispatch => { + const payload = { app_version: appVersion }; + if (firebaseToken) { + payload.firebase_token = firebaseToken; + } + + payload.app_id = installationId; + payload.node_id = nodeId; + payload.daemon_version = lbrynetVersion; + payload.operating_system = os; + payload.platform = platform; + Lbryio.call('install', 'new', payload); + }; +} + // TODO: Call doInstallNew separately so we don't have to pass appVersion and os_system params? export function doAuthenticate( appVersion, os = null, firebaseToken = null, shareUsageData = true, - callbackForUsersWhoAreSharingData + callbackForUsersWhoAreSharingData, + callInstall = true ) { return dispatch => { dispatch({ @@ -96,7 +121,9 @@ export function doAuthenticate( if (shareUsageData) { dispatch(doRewardList()); dispatch(doFetchInviteStatus()); - doInstallNew(appVersion, os, firebaseToken, callbackForUsersWhoAreSharingData); + if (callInstall) { + doInstallNew(appVersion, os, firebaseToken, callbackForUsersWhoAreSharingData); + } } }); })