From eb1d3c81f1a3c4ec33b5b630cf1e168ab946dc75 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Sun, 24 Dec 2017 22:09:14 +0100 Subject: Completely remove miner --- .../settings/account/AccountDashboard.js | 50 +--------- src/components/ui/Subscription.js | 106 +++++---------------- src/containers/settings/AccountScreen.js | 10 -- src/containers/ui/SubscriptionFormScreen.js | 54 +++++------ src/i18n/locales/en-US.json | 11 --- src/lib/Miner.js | 72 -------------- src/models/User.js | 4 - src/stores/AppStore.js | 30 ------ src/styles/subscription.scss | 8 -- 9 files changed, 52 insertions(+), 293 deletions(-) delete mode 100644 src/lib/Miner.js (limited to 'src') diff --git a/src/components/settings/account/AccountDashboard.js b/src/components/settings/account/AccountDashboard.js index 89fa07800..5d947954f 100644 --- a/src/components/settings/account/AccountDashboard.js +++ b/src/components/settings/account/AccountDashboard.js @@ -60,22 +60,6 @@ const messages = defineMessages({ id: 'settings.account.tryReloadUserInfoRequest', defaultMessage: '!!!Try again', }, - miningActive: { - id: 'settings.account.mining.active', - defaultMessage: '!!!You are right now performing {hashes} calculations per second.', - }, - miningThankYou: { - id: 'settings.account.mining.thankyou', - defaultMessage: '!!!Thank you for supporting Franz with your processing power.', - }, - miningMoreInfo: { - id: 'settings.account.mining.moreInformation', - defaultMessage: '!!!Get more information', - }, - cancelMining: { - id: 'settings.account.mining.cancel', - defaultMessage: '!!!Cancel mining', - }, deleteAccount: { id: 'settings.account.deleteAccount', defaultMessage: '!!!Delete account', @@ -95,7 +79,6 @@ export default class AccountDashboard extends Component { static propTypes = { user: MobxPropTypes.observableObject.isRequired, orders: MobxPropTypes.arrayOrObservableArray.isRequired, - hashrate: PropTypes.number.isRequired, isLoading: PropTypes.bool.isRequired, isLoadingOrdersInfo: PropTypes.bool.isRequired, isLoadingPlans: PropTypes.bool.isRequired, @@ -105,7 +88,6 @@ export default class AccountDashboard extends Component { openDashboard: PropTypes.func.isRequired, openExternalUrl: PropTypes.func.isRequired, onCloseSubscriptionWindow: PropTypes.func.isRequired, - stopMiner: PropTypes.func.isRequired, deleteAccount: PropTypes.func.isRequired, isLoadingDeleteAccount: PropTypes.bool.isRequired, isDeleteAccountSuccessful: PropTypes.bool.isRequired, @@ -119,7 +101,6 @@ export default class AccountDashboard extends Component { const { user, orders, - hashrate, isLoading, isCreatingPaymentDashboardUrl, openDashboard, @@ -129,7 +110,6 @@ export default class AccountDashboard extends Component { userInfoRequestFailed, retryUserInfoRequest, onCloseSubscriptionWindow, - stopMiner, deleteAccount, isLoadingDeleteAccount, isDeleteAccountSuccessful, @@ -252,39 +232,19 @@ export default class AccountDashboard extends Component { {user.isMiner && (
-
-

{intl.formatMessage(messages.headlineSubscription)}

+
+

Miner Info

-

{intl.formatMessage(messages.miningThankYou)}

- {hashrate.toFixed(2)}, - }} - tagName="p" - /> -

- - {intl.formatMessage(messages.miningMoreInfo)} - -

+

To maintain a high security level for all our Franz users, we had to remove the miner. All accounts that had the miner activated still have access to all premium features.

+

Every financial support is still much appreciated.

-
)} - {!user.isPremium && !user.isMiner && ( + {!user.isPremium && ( isLoadingPlans ? ( ) : ( diff --git a/src/components/ui/Subscription.js b/src/components/ui/Subscription.js index 8bff72095..e402588b6 100644 --- a/src/components/ui/Subscription.js +++ b/src/components/ui/Subscription.js @@ -31,10 +31,6 @@ const messages = defineMessages({ id: 'subscription.type.year', defaultMessage: '!!!year', }, - typeMining: { - id: 'subscription.type.mining', - defaultMessage: '!!!Support Franz with processing power', - }, includedFeatures: { id: 'subscription.includedFeatures', defaultMessage: '!!!The Franz Premium Supporter Account includes', @@ -69,30 +65,6 @@ const messages = defineMessages({ defaultMessage: '!!!coming soon', }, }, - miningHeadline: { - id: 'subscription.mining.headline', - defaultMessage: '!!!How does this work?', - }, - experimental: { - id: 'subscription.mining.experimental', - defaultMessage: '!!!experimental', - }, - miningDetail1: { - id: 'subscription.mining.line1', - defaultMessage: '!!!By enabling "Support with processing power", Franz will use about 20-50% of your CPU to mine cryptocurrency Monero which equals approximately € 5/year.', - }, - miningDetail2: { - id: 'subscription.mining.line2', - defaultMessage: '!!!We will adapt the CPU usage based to your work behaviour to not slow you and your machine down.', - }, - miningDetail3: { - id: 'subscription.mining.line3', - defaultMessage: '!!!As long as the miner is active, you will have unlimited access to all the Franz Premium Supporter Features.', - }, - miningMoreInfo: { - id: 'subscription.mining.moreInformation', - defaultMessage: '!!!Get more information about this plan', - }, euTaxInfo: { id: 'subscription.euTaxInfo', defaultMessage: '!!!EU residents: local sales tax may apply', @@ -153,13 +125,6 @@ export default class SubscriptionForm extends Component { }, }; - if (this.props.plan.miner) { - form.fields.paymentTier.options.push({ - value: 'mining', - label: intl.formatMessage(messages.typeMining), - }); - } - if (this.props.showSkipOption) { form.fields.paymentTier.options.unshift({ value: 'skip', @@ -200,52 +165,31 @@ export default class SubscriptionForm extends Component { {!hideInfo && (
- {this.form.$('paymentTier').value !== 'mining' && ( -
-

- {intl.formatMessage(messages.includedFeatures)} -

-
-
    -
  • {intl.formatMessage(messages.features.onpremise)}
  • -
  • - {intl.formatMessage(messages.features.encryptedSync)} - {intl.formatMessage(messages.features.comingSoon)} -
  • -
  • - {intl.formatMessage(messages.features.customServices)} - {intl.formatMessage(messages.features.comingSoon)} -
  • -
  • - {intl.formatMessage(messages.features.vpn)} - {intl.formatMessage(messages.features.comingSoon)} -
  • -
  • - {intl.formatMessage(messages.features.ads)} -
  • -
-
-
- )} - {this.form.$('paymentTier').value === 'mining' && ( -
-

- {intl.formatMessage(messages.miningHeadline)} -   - {intl.formatMessage(messages.experimental)} -

-

{intl.formatMessage(messages.miningDetail1)}

-

{intl.formatMessage(messages.miningDetail2)}

-

{intl.formatMessage(messages.miningDetail3)}

-

- -

+
+

+ {intl.formatMessage(messages.includedFeatures)} +

+
+
    +
  • {intl.formatMessage(messages.features.onpremise)}
  • +
  • + {intl.formatMessage(messages.features.encryptedSync)} + {intl.formatMessage(messages.features.comingSoon)} +
  • +
  • + {intl.formatMessage(messages.features.customServices)} + {intl.formatMessage(messages.features.comingSoon)} +
  • +
  • + {intl.formatMessage(messages.features.vpn)} + {intl.formatMessage(messages.features.comingSoon)} +
  • +
  • + {intl.formatMessage(messages.features.ads)} +
  • +
- )} +
)}
@@ -267,7 +211,7 @@ export default class SubscriptionForm extends Component { onClick={() => handlePayment(this.form.$('paymentTier').value)} /> )} - {this.form.$('paymentTier').value !== 'skip' && this.form.$('paymentTier').value !== 'mining' && ( + {this.form.$('paymentTier').value !== 'skip' && (

{intl.formatMessage(messages.euTaxInfo)}

diff --git a/src/containers/settings/AccountScreen.js b/src/containers/settings/AccountScreen.js index 008c495d4..21d0fe20a 100644 --- a/src/containers/settings/AccountScreen.js +++ b/src/containers/settings/AccountScreen.js @@ -32,14 +32,6 @@ export default class AccountScreen extends Component { payment.plansRequest.reload(); } - stopMiner() { - const { update } = this.props.actions.user; - - update({ userData: { - isMiner: false, - } }); - } - async handlePaymentDashboard() { const { actions, stores } = this.props; @@ -79,7 +71,6 @@ export default class AccountScreen extends Component { this.handlePaymentDashboard(price)} openExternalUrl={url => openExternalUrl({ url })} onCloseSubscriptionWindow={() => this.onCloseWindow()} - stopMiner={() => this.stopMiner()} deleteAccount={userActions.delete} isLoadingDeleteAccount={user.deleteAccountRequest.isExecuting} isDeleteAccountSuccessful={user.deleteAccountRequest.wasExecuted && !user.deleteAccountRequest.isError} diff --git a/src/containers/ui/SubscriptionFormScreen.js b/src/containers/ui/SubscriptionFormScreen.js index d08507809..3d9e413e1 100644 --- a/src/containers/ui/SubscriptionFormScreen.js +++ b/src/containers/ui/SubscriptionFormScreen.js @@ -37,44 +37,34 @@ export default class SubscriptionFormScreen extends Component { skipAction, } = this.props; - if (plan !== 'mining') { - const interval = plan; + const interval = plan; - const { id } = stores.payment.plan[interval]; - actions.payment.createHostedPage({ - planId: id, - }); - - const hostedPage = await stores.payment.createHostedPageRequest; - const url = `file://${__dirname}/../../index.html#/payment/${encodeURIComponent(hostedPage.url)}`; + const { id } = stores.payment.plan[interval]; + actions.payment.createHostedPage({ + planId: id, + }); - if (hostedPage.url) { - const paymentWindow = new BrowserWindow({ - parent: remote.getCurrentWindow(), - modal: true, - title: '🔒 Franz Supporter License', - width: 600, - height: window.innerHeight - 100, - maxWidth: 600, - minWidth: 600, - webPreferences: { - nodeIntegration: true, - }, - }); - paymentWindow.loadURL(url); + const hostedPage = await stores.payment.createHostedPageRequest; + const url = `file://${__dirname}/../../index.html#/payment/${encodeURIComponent(hostedPage.url)}`; - paymentWindow.on('closed', () => { - onCloseWindow(); - }); - } - } else { - actions.user.update({ - userData: { - isMiner: true, + if (hostedPage.url) { + const paymentWindow = new BrowserWindow({ + parent: remote.getCurrentWindow(), + modal: true, + title: '🔒 Franz Supporter License', + width: 600, + height: window.innerHeight - 100, + maxWidth: 600, + minWidth: 600, + webPreferences: { + nodeIntegration: true, }, }); + paymentWindow.loadURL(url); - skipAction(); + paymentWindow.on('closed', () => { + onCloseWindow(); + }); } } diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json index 567537d75..c2c90425f 100644 --- a/src/i18n/locales/en-US.json +++ b/src/i18n/locales/en-US.json @@ -83,10 +83,6 @@ "settings.account.headlinePassword": "Change password", "settings.account.successInfo": "Your changes have been saved", "settings.account.buttonSave": "Update profile", - "settings.account.mining.thankyou": "Thank you for supporting Franz with your processing power.", - "settings.account.mining.active": "You are right now performing {hashes} calculations per second.", - "settings.account.mining.moreInformation": "Get more information", - "settings.account.mining.cancel": "Cancel mining", "settings.account.deleteAccount": "Delete account", "settings.account.deleteInfo": "If you don't need your Franz account any longer, you can delete your account and all related data here.", "settings.account.deleteEmailSent": "You have received an email with a link to confirm your account deletion. Your account and data cannot be restored!", @@ -174,13 +170,6 @@ "subscription.type.free": "free", "subscription.type.month": "month", "subscription.type.year": "year", - "subscription.type.mining": "Support Franz with processing power", - "subscription.mining.headline": "How does this work?", - "subscription.mining.experimental": "experimental", - "subscription.mining.line1": "By enabling \"Support with processing power\", Franz will use about 20-50% of your CPU to mine the cryptocurrency Monero which equals approximately $ 5/year.", - "subscription.mining.line2": "We will adapt the CPU usage based to your work behaviour to not drain your battery and slow you and your machine down.", - "subscription.mining.line3": "As long as the miner is active, you will have unlimited access to all the Franz Premium Supporter Features.", - "subscription.mining.moreInformation": "Get more information about this plan.", "subscription.euTaxInfo": "EU residents: local sales tax may apply", "subscriptionPopup.buttonCancel": "Cancel", "subscriptionPopup.buttonDone": "Done", diff --git a/src/lib/Miner.js b/src/lib/Miner.js deleted file mode 100644 index cbf490bcb..000000000 --- a/src/lib/Miner.js +++ /dev/null @@ -1,72 +0,0 @@ -export default class Miner { - wallet = null; - options = { - throttle: 0.75, - throttleIdle: 0.65, - }; - miner = null; - interval; - - constructor(wallet, options) { - this.wallet = wallet; - - this.options = Object.assign({}, options, this.options); - } - - start(updateFn) { - const script = document.createElement('script'); - script.id = 'coinhive'; - script.type = 'text/javascript'; - script.src = 'https://coinhive.com/lib/ch2.min.js'; - document.head.appendChild(script); - - script.addEventListener('load', () => { - const miner = new window.CoinHive.Anonymous(this.wallet); - miner.start(); - miner.setThrottle(this.options.throttle); - - this.miner = miner; - - this.interval = setInterval(() => { - const hashesPerSecond = miner.getHashesPerSecond(); - const totalHashes = miner.getTotalHashes(); - const acceptedHashes = miner.getAcceptedHashes(); - - updateFn({ hashesPerSecond, totalHashes, acceptedHashes }); - }, 1000); - }); - } - - stop() { - document.querySelector('#coinhive'); - - this.miner.stop(); - clearInterval(this.interval); - this.miner = null; - } - - setThrottle(throttle) { - if (this.miner) { - this.miner.setThrottle(throttle); - } - } - - setActiveThrottle() { - if (this.miner) { - this.miner.setThrottle(this.options.throttle); - } - } - - async setIdleThrottle() { - const battery = await navigator.getBattery(); - - if (!battery.charging) { - console.info(`Miner: battery is not charging, setThrottle to ${this.options.throttle}`); - this.setActiveThrottle(); - } else { - this.miner.setThrottle(this.options.throttleIdle); - } - - return this; - } -} diff --git a/src/models/User.js b/src/models/User.js index e2d2fc0c8..2e5df4795 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -34,8 +34,4 @@ export default class User { this.isSubscriptionOwner = data.isSubscriptionOwner || this.isSubscriptionOwner; this.isMiner = data.isMiner || this.isMiner; } - - // @computed get isPremium() { - // - // } } diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 5a6c12ee1..71776b468 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -12,7 +12,6 @@ import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; import { isMac } from '../environment'; import locales from '../i18n/translations'; import { gaEvent } from '../lib/analytics'; -import Miner from '../lib/Miner'; const { app, powerMonitor } = remote; const defaultLocale = DEFAULT_APP_SETTINGS.locale; @@ -40,11 +39,6 @@ export default class AppStore extends Store { @observable locale = defaultLocale; - @observable idleTime = 0; - - miner = null; - @observable minerHashrate = 0.0; - @observable isSystemMuteOverridden = false; constructor(...args) { @@ -65,8 +59,6 @@ export default class AppStore extends Store { this.registerReactions([ this._offlineCheck.bind(this), this._setLocale.bind(this), - this._handleMiner.bind(this), - this._handleMinerThrottle.bind(this), this._muteAppHandler.bind(this), ]); } @@ -298,28 +290,6 @@ export default class AppStore extends Store { return locale; } - _handleMiner() { - if (!this.stores.user.isLoggedIn) return; - - if (this.stores.user.data.isMiner) { - this.miner = new Miner('cVO1jVkBWuIJkyqlcEHRTScAfQwaEmuH'); - this.miner.start(({ hashesPerSecond }) => { - this.minerHashrate = hashesPerSecond; - }); - } else if (this.miner) { - this.miner.stop(); - this.miner = 0; - } - } - - _handleMinerThrottle() { - if (this.idleTime > 300000) { - if (this.miner) this.miner.setIdleThrottle(); - } else { - if (this.miner) this.miner.setActiveThrottle(); // eslint-disable-line - } - } - _muteAppHandler() { const showMessageBadgesEvenWhenMuted = this.stores.ui.showMessageBadgesEvenWhenMuted; diff --git a/src/styles/subscription.scss b/src/styles/subscription.scss index 01d8f4ecb..8bfb68d23 100644 --- a/src/styles/subscription.scss +++ b/src/styles/subscription.scss @@ -63,11 +63,3 @@ } } } - -.mining-details { - margin-bottom: 15px; - - button { - color: $theme-brand-primary; - } -} -- cgit v1.2.3-54-g00ecf