Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wallet] Add timestamp to top banner messages #1657

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add timestamp to top banner messages
This would allow to show the same message again if needed
  • Loading branch information
i1skn committed Nov 11, 2019
commit e14d65dabc0be89e63c0cbf032d1526e4dc2bdab
1 change: 1 addition & 0 deletions packages/mobile/src/alert/AlertBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class AlertBanner extends React.Component<Props> {

return (
<SmartTopAlert
timestamp={Date.now()}
text={alert && alert.message}
onPress={hideAlertAction}
type={alert && alert.type === 'error' ? NotificationTypes.ERROR : NotificationTypes.MESSAGE}
Expand Down
33 changes: 18 additions & 15 deletions packages/mobile/src/invite/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { sanitizeBase64 } from '@celo/walletkit'
import URLSearchParamsReal from '@ungap/url-search-params'
import { Platform } from 'react-native'
import RNInstallReferrer from 'react-native-install-referrer'
import Logger from 'src/utils/Logger'

Expand Down Expand Up @@ -53,23 +54,25 @@ interface ReferrerDataError {
}

export const getValidInviteCodeFromReferrerData = async () => {
const referrerData: ReferrerData | ReferrerDataError = await RNInstallReferrer.getReferrer()
Logger.info(
'invite/utils/getInviteCodeFromReferrerData',
'Referrer Data: ' + JSON.stringify(referrerData)
)
if (referrerData && referrerData.hasOwnProperty('installReferrer')) {
const params = new URLSearchParamsReal(
decodeURIComponent((referrerData as ReferrerData).installReferrer)
if (Platform.OS === 'android') {
const referrerData: ReferrerData | ReferrerDataError = await RNInstallReferrer.getReferrer()
Logger.info(
'invite/utils/getInviteCodeFromReferrerData',
'Referrer Data: ' + JSON.stringify(referrerData)
)
const inviteCode = params.get('invite-code')
if (inviteCode) {
const sanitizedCode = inviteCode.replace(' ', '+')
// Accept invite codes which are either base64 encoded or direct hex keys
if (isValidPrivateKey(sanitizedCode)) {
return sanitizedCode
if (referrerData && referrerData.hasOwnProperty('installReferrer')) {
const params = new URLSearchParamsReal(
decodeURIComponent((referrerData as ReferrerData).installReferrer)
)
const inviteCode = params.get('invite-code')
if (inviteCode) {
const sanitizedCode = inviteCode.replace(' ', '+')
// Accept invite codes which are either base64 encoded or direct hex keys
if (isValidPrivateKey(sanitizedCode)) {
return sanitizedCode
}
return extractValidInviteCode(sanitizedCode)
}
return extractValidInviteCode(sanitizedCode)
}
}
return null
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/src/shared/BackupPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class BackupPrompt extends React.Component<Props> {

return (
<SmartTopAlert
timestamp={Date.now()}
text={isVisible && t('backupPrompt')}
onPress={this.goToBackup}
type={NotificationTypes.MESSAGE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('SmartTopAlert', () => {
it('renders correctly', async () => {
const { toJSON } = render(
<SmartTopAlert
timestamp={Date.now()}
dismissAfter={5}
title={'Smart Top Alert'}
text="dont get funny"
Expand Down
11 changes: 10 additions & 1 deletion packages/react-components/components/SmartTopAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum NotificationTypes {
}

interface Props {
timestamp: number
title?: string | null
text: string | null
onPress: () => void
Expand Down Expand Up @@ -48,7 +49,15 @@ function SmartTopAlert(props: Props) {
return null
}
},
[props.type, props.title, props.text, props.buttonMessage, props.dismissAfter, props.onPress]
[
props.timestamp,
props.type,
props.title,
props.text,
props.buttonMessage,
props.dismissAfter,
props.onPress,
]
)

function hide() {
Expand Down
1 change: 1 addition & 0 deletions packages/verifier/src/components/ErrorBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class ErrorBox extends React.Component<Props> {

return (
<SmartTopAlert
timestamp={Date.now()}
text={error && t(error)}
onPress={clearErrorAction}
type={NotificationTypes.ERROR}
Expand Down
1 change: 1 addition & 0 deletions packages/verifier/src/components/MessageBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class MessageBanner extends React.Component<Props> {

return (
<SmartTopAlert
timestamp={Date.now()}
text={message}
title={title}
onPress={clearMessageAction}
Expand Down