Skip to content
Permalink
Browse files

set flag in storage

  • Loading branch information...
rastajpa committed Jun 4, 2019
1 parent df8e97b commit 85fae77ad00cb3a332f499842b67f3ab0840e26a
@@ -32,7 +32,6 @@
"glidera": false,
"debitcard": true,
"shapeshift": true,
"giftcards": true,
"pricechart": true
"giftcards": true
}
}
@@ -32,7 +32,6 @@
"glidera": false,
"debitcard": false,
"shapeshift": false,
"giftcards": false,
"pricechart": true
"giftcards": false
}
}
@@ -180,6 +180,7 @@
"bitauth": "git+https://github.com/bitpay/bitauth.git#copay",
"bitcore-wallet-client": "8.3.3",
"buffer-compare": "1.1.1",
"chart.js": "2.8.0",
"cordova": "8.1.2",
"cordova-android": "7.1.2",
"cordova-clipboard": "1.2.1",
@@ -25,7 +25,6 @@ import { IncomingDataProvider } from '../providers/incoming-data/incoming-data';
import { Logger } from '../providers/logger/logger';
import { PlatformProvider } from '../providers/platform/platform';
import { PopupProvider } from '../providers/popup/popup';
import { PriceProvider } from '../providers/price/price';
import { ProfileProvider } from '../providers/profile/profile';
import { PushNotificationsProvider } from '../providers/push-notifications/push-notifications';
import { ShapeshiftProvider } from '../providers/shapeshift/shapeshift';
@@ -116,8 +115,7 @@ export class CopayApp {
private walletTabsProvider: WalletTabsProvider,
private renderer: Renderer,
private userAgent: UserAgent,
private device: Device,
private priceProvider: PriceProvider
private device: Device
) {
this.imageLoaderConfig.setFileNameCachedWithExtension(true);
this.imageLoaderConfig.useImageTag(true);
@@ -330,10 +328,6 @@ export class CopayApp {
// BitPay Card
if (this.appProvider.info._enabledExtensions.debitcard)
this.bitPayCardProvider.register();

// Price Chart
if (this.appProvider.info._enabledExtensions.pricechart)
this.priceProvider.register();
}

private incomingDataRedirEvent(): void {
@@ -1,6 +1,6 @@
<ion-card>
<ion-card-content>
<ion-slides speed="500" autoplay="true">
<ion-slides speed="500">
<ion-slide *ngFor="let coin of coins; let i = index">
<ion-item>
<ion-avatar item-start>
@@ -18,8 +18,11 @@ export class PriceChart {
}

drawCanvas(coin) {
let rates = _.map(coin.historicalRates, (rate, i) => {
return { x: rate, y: `${i}` };
let rates = [];
let labels = [];
_.map(coin.historicalRates, (rate, i) => {
rates.push(rate);
labels.push(`${i}`);
});
const context: CanvasRenderingContext2D = (this.lineCanvas
.nativeElement as HTMLCanvasElement).getContext('2d');
@@ -60,12 +63,14 @@ export class PriceChart {
padding: {
bottom: 10,
top: 10,
left: 2,
right: 2
left: 5,
right: 5
}
}
};

const data = {
labels,
datasets: [
{
fill: true,
@@ -135,6 +135,8 @@ export class HomePage {
if (this.isElectron) {
this.updateDesktopOnFocus();
}

this.checkPriceChart();
}

private _didEnter() {
@@ -143,12 +145,7 @@ export class HomePage {
// Show integrations
const integrations = _.filter(this.homeIntegrationsProvider.get(), {
show: true
}).filter(
i =>
i.name !== 'giftcards' &&
i.name !== 'debitcard' &&
i.name !== 'pricechart'
);
}).filter(i => i.name !== 'giftcards' && i.name !== 'debitcard');

this.showGiftCards = this.homeIntegrationsProvider.shouldShowInHome(
'giftcards'
@@ -158,10 +155,6 @@ export class HomePage {
'debitcard'
);

this.showPriceChart = this.homeIntegrationsProvider.shouldShowInHome(
'pricechart'
);

// Hide BitPay if linked
setTimeout(() => {
this.homeIntegrations = _.remove(_.clone(integrations), x => {
@@ -179,8 +172,6 @@ export class HomePage {
this.bitpayCardItems = cards;
});
});

this.updateChart();
}

private walletFocusHandler = opts => {
@@ -391,6 +382,26 @@ export class HomePage {
});
}

private checkPriceChart() {
this.persistenceProvider.getPriceChartFlag().then(res => {
if (!res) {
this.initPriceChart();
} else {
this.showPriceChart = res === 'enabled' ? true : false;
this.updateCharts();
}
});
}

private initPriceChart() {
this.persistenceProvider.setPriceChartFlag('disabled');
this.showPriceChart = false;
}

private updateCharts() {
if (this.showPriceChart && this.priceCard) this.priceCard.updateCharts();
}

public onWalletAction(wallet, action, slidingItem) {
const tabMap = {
receive: 0,
@@ -807,7 +818,7 @@ export class HomePage {
public doRefresh(refresher): void {
this.debounceSetWallets();
setTimeout(() => {
this.updateChart();
this.updateCharts();
refresher.complete();
}, 2000);
}
@@ -842,8 +853,4 @@ export class HomePage {
this.getLastKownBalance(wallet, currecy) === '0.00'
);
}

public updateChart() {
if (this.showPriceChart && this.priceCard) this.priceCard.updateCharts();
}
}
@@ -7,7 +7,7 @@
<ion-content>
<ion-list class="settings-list">
<ion-item-divider>{{'Release information'| translate}}</ion-item-divider>
<ion-item>
<ion-item (tap)="itemTapped()">
<ion-icon class="custom-icon" name="ios-download-outline" item-start></ion-icon>
{{'Version' | translate}}
<ion-note item-end>
@@ -20,7 +20,7 @@
<ion-note item-end>
#{{commitHash}}
</ion-note>
</ion-item>
</ion-item>
<ion-item-divider class="item-without-title"></ion-item-divider>
<button ion-item (click)="openSendFeedbackPage()">
<ion-icon class="item-img" item-start>
@@ -36,8 +36,8 @@
<button ion-item (click)="openTermsOfUse()">
<ion-icon class="custom-icon" name="ios-list-box-outline" item-start></ion-icon>
{{'Terms of Use' | translate }}
</button>
<ion-item-divider class="item-without-title"></ion-item-divider>
</button>
<ion-item-divider class="item-without-title"></ion-item-divider>
<button ion-item (click)="openSessionLog()">
<ion-icon class="custom-icon" name="ios-copy-outline" item-start></ion-icon>
{{ 'Session log' | translate }}
@@ -1,17 +1,19 @@
import { Component } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { NavController } from 'ionic-angular';
import { Logger } from '../../../providers/logger/logger';

// pages
import { SendFeedbackPage } from '../../feedback/send-feedback/send-feedback';
import { SessionLogPage } from './session-log/session-log';

// providers
import { AppProvider } from '../../../providers/app/app';
import { ExternalLinkProvider } from '../../../providers/external-link/external-link';
import { ReplaceParametersProvider } from '../../../providers/replace-parameters/replace-parameters';

import {
AppProvider,
ExternalLinkProvider,
Logger,
PersistenceProvider,
ReplaceParametersProvider
} from '../../../providers';
@Component({
selector: 'page-about',
templateUrl: 'about.html'
@@ -20,15 +22,19 @@ export class AboutPage {
public version: string;
public commitHash: string;
public title: string;
public versionItemTapped: number;

constructor(
private navCtrl: NavController,
private appProvider: AppProvider,
private logger: Logger,
private externalLinkProvider: ExternalLinkProvider,
private replaceParametersProvider: ReplaceParametersProvider,
private translate: TranslateService
) {}
private translate: TranslateService,
private persistenceProvider: PersistenceProvider
) {
this.versionItemTapped = 0;
}

ionViewDidLoad() {
this.logger.info('Loaded: AboutPage');
@@ -105,4 +111,15 @@ export class AboutPage {
public openSendFeedbackPage(): void {
this.navCtrl.push(SendFeedbackPage);
}

public itemTapped() {
this.versionItemTapped++;
if (this.versionItemTapped >= 5) {
this.versionItemTapped = 0;
this.persistenceProvider.getPriceChartFlag().then(res => {
const showPriceChart = res === 'disabled' ? 'enabled' : 'disabled';
this.persistenceProvider.setPriceChartFlag(showPriceChart);
});
}
}
}
@@ -5,17 +5,6 @@
</ion-header>

<ion-content>
<ion-list class="settings-list">
<ion-item class="with-label no-border">
<ion-label>{{'Show Price Chart' | translate}}</ion-label>
<ion-toggle [(ngModel)]="showAtHome" (ionChange)="integrationChange()"></ion-toggle>
</ion-item>
<label-tip class="info" type="info" header="no-header">
<div label-tip-body>
<div translate>If enabled, the price of the cryptocurrencies will be displayed on the home screen.</div>
</div>
</label-tip>
</ion-list>
<ion-list class="settings-list">
<ion-item class="with-label no-border">
<ion-label>{{'Use Unconfirmed Funds' | translate}}</ion-label>
@@ -1,13 +1,7 @@
import { Component } from '@angular/core';
import * as _ from 'lodash';

// providers
import {
AppProvider,
ConfigProvider,
HomeIntegrationsProvider,
Logger
} from '../../../providers';
import { AppProvider, ConfigProvider, Logger } from '../../../providers';

@Component({
selector: 'page-advanced',
@@ -16,22 +10,15 @@ import {
export class AdvancedPage {
public spendUnconfirmed: boolean;
public isCopay: boolean;
private serviceName: string = 'pricechart';
public showAtHome;
public service;

public bitpayCard;

constructor(
private configProvider: ConfigProvider,
private logger: Logger,
private appProvider: AppProvider,
private homeIntegrationsProvider: HomeIntegrationsProvider
private appProvider: AppProvider
) {
this.isCopay = this.appProvider.info.name === 'copay';
this.service = _.filter(this.homeIntegrationsProvider.get(), {
name: this.serviceName
});
this.showAtHome = !!this.service[0].show;
}

ionViewDidLoad() {
@@ -52,15 +39,4 @@ export class AdvancedPage {
};
this.configProvider.set(opts);
}

public integrationChange(): void {
let opts = {
showIntegration: { [this.serviceName]: this.showAtHome }
};
this.homeIntegrationsProvider.updateConfig(
this.serviceName,
this.showAtHome
);
this.configProvider.set(opts);
}
}
@@ -104,10 +104,7 @@ export class SettingsPage {

ionViewDidEnter() {
// Show integrations
const integrations = _.filter(
this.homeIntegrationsProvider.get(),
i => i.name !== 'pricechart'
);
const integrations = this.homeIntegrationsProvider.get();

// Hide BitPay if linked
setTimeout(() => {
@@ -67,7 +67,6 @@ export interface Config {
mercadolibre: boolean;
shapeshift: boolean;
giftcards: boolean;
pricechart: boolean;
};

pushNotificationsEnabled: boolean;
@@ -178,8 +177,7 @@ export class ConfigProvider {
amazon: true,
mercadolibre: true,
shapeshift: true,
giftcards: true,
pricechart: true
giftcards: true
},

pushNotificationsEnabled: true,
@@ -280,9 +278,6 @@ export class ConfigProvider {
if (this.configCache.showIntegration.giftcards !== false) {
this.configCache.showIntegration.giftcards = this.configDefault.showIntegration.giftcards;
}
if (this.configCache.showIntegration.pricechart !== false) {
this.configCache.showIntegration.pricechart = this.configDefault.showIntegration.pricechart;
}
}
if (!this.configCache.pushNotificationsEnabled) {
this.configCache.pushNotificationsEnabled = this.configDefault.pushNotificationsEnabled;

0 comments on commit 85fae77

Please sign in to comment.
You can’t perform that action at this time.