Skip to content

Commit

Permalink
Merge pull request #160 from bcProFoundation/ericson-polish-ui-01042023
Browse files Browse the repository at this point in the history
change action sheet scan, edit vi translate,...
  • Loading branch information
kensauruss authored Apr 1, 2023
2 parents aa2d1b5 + d1bf5ed commit e0cc7a9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/app/components/info-sheet/info-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@
<span sheet-second-button-text translate>GOT IT</span>
</info-sheet-template>

<info-sheet-template *ngSwitchCase="'scan-eToken-error-message'" type="danger">
<span sheet-title-text translate>Error</span>
<info-sheet-template *ngSwitchCase="'scan-eToken-error-message'" type="warning">
<span sheet-title-text translate>Warning</span>
<span sheet-text translate>
The account you are using does not match the network and/or the currency of the address provided
</span>
Expand Down
5 changes: 3 additions & 2 deletions src/app/pages/accounts/accounts.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
</ng-container>
<ng-template #showNoToken>
<ion-content>
<div class="error-scan-etoken">
<!-- TODO: Check action sheet is working well? -->
<!-- <div class="error-scan-etoken">
<div class="error-title">
<img src="assets/img/icon-warning-circled.svg">
<h1 translate>Warning</h1>
Expand All @@ -143,6 +144,6 @@ <h1 translate>Warning</h1>
<ion-button fill="clear" (click)="goToHome()">
Ok
</ion-button>
</div>
</div> -->
</ion-content>
</ng-template>
8 changes: 8 additions & 0 deletions src/app/pages/accounts/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ export class AccountsPage {
// Only 1 token account in list => go to send page
if (this.isSpecificAmount && tokensGroups.length === 0) {
this.isShowNoToken = true;
this.router.navigate(['']).then(() => {
const warningSheet = this.actionSheetProvider.createInfoSheet('scan-eToken-error-message');
warningSheet.present();
});
} else if (this.isSpecificAmount && tokensGroups.length === 1) {
this.goToSendPageForToken(tokensGroups[0].walletId, tokensGroups[0], true);
}
Expand All @@ -187,6 +191,10 @@ export class AccountsPage {
// Check ExistToken
if (tokensGroups.length === 0) {
this.isShowNoToken = true;
this.router.navigate(['']).then(() => {
const warningSheet = this.actionSheetProvider.createInfoSheet('scan-eToken-error-message');
warningSheet.present();
});
}
}

Expand Down
91 changes: 48 additions & 43 deletions src/app/providers/push-notifications/push-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { timer } from 'rxjs';
import { FCM } from "@capacitor-community/fcm";
import { FCM } from '@capacitor-community/fcm';

// providers
import { AppProvider } from '../app/app';
Expand Down Expand Up @@ -69,30 +69,33 @@ export class PushNotificationsProvider {
this.appProvider.info.name != 'copay' &&
config.offersAndPromotions.enabled
)
await this.subscribeToTopic('offersandpromotions');
await this.subscribeToTopic('offersandpromotions');
if (
this.appProvider.info.name != 'copay' &&
config.productsUpdates.enabled
)
await this.subscribeToTopic('productsupdates');
await this.subscribeToTopic('productsupdates');

this.fcmInterval = setInterval(() => {
this.renewSubscription();
}, 5 * 60 * 1000); // 5 min
});

// Show us the notification payload if the app is open on our device
PushNotifications.addListener('pushNotificationReceived',
PushNotifications.addListener(
'pushNotificationReceived',
(notification: PushNotificationSchema) => {
return this.handlePushNotifications(notification);
}
);

// Method called when tapping on a notification
PushNotifications.addListener('pushNotificationActionPerformed',
PushNotifications.addListener(
'pushNotificationActionPerformed',
async (notification: ActionPerformed) => {
return await this.handlePushNotificationsWasTapped(notification);
});
}
);
}

private async getToken() {
Expand All @@ -104,23 +107,26 @@ export class PushNotificationsProvider {
}, 5000);
return;
}
this.logger.debug('Get token for push notifications android: ' + value);
this._token = value;
})
this.logger.debug('Get token for push notifications android: ' + value);
this._token = value;
});
} else {
FCM.getToken()
.then(async token => {
if (!token) {
setTimeout(() => {
this.init();
}, 5000);
return;
}
this.logger.debug('Get token for push notifications ios: ' + token.token);
.then(async token => {
if (!token) {
setTimeout(() => {
this.init();
}, 5000);
return;
}
this.logger.debug(
'Get token for push notifications ios: ' + token.token
);
this._token = token.token;
}).catch(error=>{
this.logger.error(error);
});
})
.catch(error => {
this.logger.error(error);
});
}
}

Expand Down Expand Up @@ -154,36 +160,36 @@ export class PushNotificationsProvider {
// Notification was received on device tray and tapped by the user.
public handlePushNotificationsWasTapped(notification: ActionPerformed): void {
if (this.usePushNotifications) {
if (!this._token) return;
if (!this._token) return;
const data = _.get(notification, 'notification.data', undefined);
if (!data) return;
if (data.redir) {
this.events.publish('IncomingDataRedir', { name: data.redir });
} else if (
data.takeover_url &&
data.takeover_image &&
data.takeover_sig
) {
if (!this.verifySignature(data)) return;
this.events.publish('ShowAdvertising', data);
} else {
this._openWallet(data);
}
if (data.redir) {
this.events.publish('IncomingDataRedir', { name: data.redir });
} else if (
data.takeover_url &&
data.takeover_image &&
data.takeover_sig
) {
if (!this.verifySignature(data)) return;
this.events.publish('ShowAdvertising', data);
} else {
this._openWallet(data);
}
}
}

public handlePushNotifications(notification: PushNotificationSchema): void {
if (this.usePushNotifications) {
if (!this._token) return;
const data = notification.data
const data = notification.data;
this.logger.debug(
'New Event Push onNotification: ' + JSON.stringify(data)
);
const wallet = this.findWallet(data.walletId, data.tokenAddress);
if (!wallet) return;
this.newBwsEvent(data, wallet.credentials.walletId);
this.showInappNotification(data);
}
const wallet = this.findWallet(data.walletId, data.tokenAddress);
if (!wallet) return;
this.newBwsEvent(data, wallet.credentials.walletId);
this.showInappNotification(data);
}
}

public newBwsEvent(notification, walletId): void {
Expand Down Expand Up @@ -396,8 +402,7 @@ export class PushNotificationsProvider {
if (!data.body || data.notification_type === 'NewOutgoingTx') return;

this.notifications.unshift(data);
// TODO: Tempory disable notification in-app
// this.runNotificationsQueue();
this.runNotificationsQueue();
}

private runNotificationsQueue() {
Expand All @@ -422,12 +427,12 @@ export class PushNotificationsProvider {
cssClass: 'in-app-notification-modal'
});
this.currentNotif.onDidDismiss().then(({ data }) => {
if (data && data.action && data.action === 'openWallet') {
if (data && data.action && data.action === 'openWallet') {
this._openWallet(data);
}
this.currentNotif = null;
this.runNotificationsQueue();
})
});

await this.currentNotif.present();
data.showDone = true;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/vi.po
Original file line number Diff line number Diff line change
Expand Up @@ -3592,7 +3592,7 @@ msgid "Sending transaction..."
msgstr "Đang gửi giao dịch..."

msgid "Sending {{amount}} {{unit}} from your {{name}} account"
msgstr "Đang gửi {{amount}} {{unit}} từ {{name}} của bạn"
msgstr "Đang gửi {{amount}} {{unit}} từ tài khoản {{name}} của bạn"

msgid "Sensitive Data"
msgstr "Sensitive Data"
Expand Down

0 comments on commit e0cc7a9

Please sign in to comment.