Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
shocknet-justin authored Nov 9, 2020
2 parents 4df5c47 + e09e4ac commit e39a523
Show file tree
Hide file tree
Showing 22 changed files with 512 additions and 387 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ public void call(final Object... args) {
String id = last.substring(0,5)+"...";
int value = Integer.parseInt(res.getString("amount"));
float valueBTC = value / 100000000f;
doNotification("Transaction confirmed! "+String.valueOf(valueBTC)+" BTC","",R.drawable.icon,"");
String finalVal = "";
if(valueBTC >= 0.001){
finalVal = String.valueOf(valueBTC)+" BTC";
} else {
finalVal = res.getString("amount")+" sats";
}
doNotification("Transaction confirmed! "+finalVal,"",R.drawable.icon,"");
}catch (Exception e){
Log.d(TAG,"Tx err"+e.toString());
}
Expand Down Expand Up @@ -272,7 +278,7 @@ private void doNotification(String title,String result,int bigIcon, String icon6
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder notification = new NotificationCompat.Builder(this, DEFAULT_CHANNEL_ID)
.setSmallIcon(R.drawable.icon)
.setSmallIcon(R.drawable.icon_notification)
//.setLargeIcon(BitmapFactory.decodeResource(this.getResources(),
// bigIcon))
.setContentTitle(title)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 0 additions & 8 deletions app/components/CustomDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
TouchableOpacity,
ScrollView,
Text,
ToastAndroid,
} from 'react-native'
import { DrawerActions } from 'react-navigation-drawer'

Expand All @@ -15,7 +14,6 @@ import { ADVANCED_SCREEN } from '../screens/Advanced'
import { SEED_BACKUP } from '../screens/SeedBackup'
import { WALLET_SETTINGS } from '../screens/WalletSettings'
import { DEBUG } from '../screens/Debug'
import * as Store from '../store'

import { Colors } from '../res/css'
import ShockIcon from '../res/icons'
Expand Down Expand Up @@ -93,12 +91,6 @@ export default class CustomDrawer extends React.PureComponent {
return
}

if (screenName === DEBUG) {
const store = Store.getStore()
store.dispatch(Store.enableDebug())
ToastAndroid.show('Debug mode enabled', 800)
}

navigation.navigate(screenName)
navigation.dispatch(DrawerActions.closeDrawer())
}
Expand Down
8 changes: 1 addition & 7 deletions app/components/Post/UserInfoNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ const UserInfoNew: React.FC<Props> = ({
}) => (
<View style={CSS.styles.rowCenteredSpaceBetween}>
<View style={styles.userAndDate}>
<ConnectedShockAvatar
height={56}
publicKey={authorPublicKey}
onPress={F}
/>
<ConnectedShockAvatar height={56} publicKey={authorPublicKey} />

<Pad amount={10} insideRow />

Expand Down Expand Up @@ -101,8 +97,6 @@ const styles = StyleSheet.create({
},
})

const F = () => {}

const makeMapState = () => {
const getUser = Store.makeGetUser()

Expand Down
9 changes: 4 additions & 5 deletions app/components/Post/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,10 @@ class Post extends React.PureComponent<Props, State> {
<View style={CSS.styles.rowCenteredSpaceBetween}>
<View />

<View
// TODO: Why width100 pushes out share buton?
style={showTipBtn ? undefined : CSS.styles.opacityZero}
>
<ShockIcon width={24} height={24} />
<View style={showTipBtn ? undefined : CSS.styles.opacityZero}>
<TouchableWithoutFeedback onPress={this.toggleTipPopup}>
<ShockIcon width={24} height={24} />
</TouchableWithoutFeedback>
</View>

<TouchableWithoutFeedback onPress={this.onPressShare}>
Expand Down
1 change: 1 addition & 0 deletions app/screens/Advanced/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ type NavigationStackOptions = import('react-navigation-stack').NavigationStackOp
class AdvancedScreen extends React.PureComponent<Props, State> {
static navigationOptions: NavigationStackOptions = {
header: () => null,
headerShown: false,
// drawerIcon: () => {
// return <IconDrawerAdvancedLightning />
// },
Expand Down
64 changes: 50 additions & 14 deletions app/screens/Debug.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import React from 'react'
import { Clipboard, ScrollView, Button, Text, ToastAndroid } from 'react-native'
import {
Clipboard,
ScrollView,
Button,
Text,
ToastAndroid,
View,
} from 'react-native'
import { connect } from 'react-redux'
import uuid from 'uuid/v1'

Expand Down Expand Up @@ -29,9 +36,12 @@ interface StateProps {
token: string

deviceID: string

err: string
}

interface DispatchProps {
enableDebug(): void
disableDebug(): void
}

Expand Down Expand Up @@ -59,6 +69,9 @@ class Debug extends React.PureComponent<Props, Record<string, any>> {
s.off('*')
s.close()
})

this.props.enableDebug()
ToastAndroid.show('Debug mode enabled', 800)
}

componentWillUnmount() {
Expand Down Expand Up @@ -92,6 +105,7 @@ class Debug extends React.PureComponent<Props, Record<string, any>> {

render() {
const {
err,
chatsAmt,
deviceID,
feedPostsAmt,
Expand All @@ -104,16 +118,28 @@ class Debug extends React.PureComponent<Props, Record<string, any>> {
debugModeEnabled,
} = this.props

if (err) {
return (
<View style={CSS.styles.flexDeadCenter}>
<Text>{err}</Text>
</View>
)
}

const { handshakeAddr } = this.state

return (
<ScrollView
style={styles.container}
contentContainerStyle={CSS.styles.alignItemsCenter}
>
<Text>A random Number: {Math.random().toString()}</Text>
<Button title="Disable " onPress={this.disableDebugMode} />

<Text>Debug Mode {debugModeEnabled ? 'Enabled' : 'Disabled'}</Text>
{debugModeEnabled ? (
<Text>Debug Mode Enabled</Text>
) : (
<Text>Debug Mode Disabled</Text>
)}

<Text>Canary Socket Status:</Text>
<Text>{online ? 'Connected' : 'Disconnected'}</Text>
Expand Down Expand Up @@ -172,22 +198,32 @@ const styles = {
}

const mapStateToProps = (state: Store.State): StateProps => {
return {
chatsAmt: Object.keys(state.chat.contacts).length,
deviceID: state.connection.deviceId,
feedPostsAmt: Store.getPostsFromFollowed(state).length,
followsAmt: Store.getFollowedPublicKeys(state).length,
ownPostsAmt: Store.getOwnPosts(state).length,
receivedReqsAmt: -1,
sentReqsAmt: -1,
token: state.auth.token,
online: Store.isOnline(state),
debugModeEnabled: state.debug.enabled,
console.log('map state to props called' + JSON.stringify(state.debug))
try {
return {
chatsAmt: Object.keys(state.chat.contacts).length,
deviceID: state.connection.deviceId,
feedPostsAmt: Store.getPostsFromFollowed(state).length,
followsAmt: Store.getFollowedPublicKeys(state).length,
ownPostsAmt: Store.getOwnPosts(state).length,
receivedReqsAmt: -1,
sentReqsAmt: -1,
token: state.auth.token,
online: Store.isOnline(state),
debugModeEnabled: state.debug.enabled,
err: '',
}
} catch (e) {
// @ts-expect-error
return {
err: e.message,
}
}
}

const mapDispatch = {
disableDebug: Store.disableDebug,
enableDebug: Store.enableDebug,
}

export default connect(
Expand Down
1 change: 1 addition & 0 deletions app/screens/MyProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class MyProfile extends React.PureComponent<Props, State> {
toggleSetupDisplayName = () => {
this.setState(({ displayNameDialogOpen }) => ({
displayNameDialogOpen: !displayNameDialogOpen,
settingDisplayName: false,
}))
}

Expand Down
5 changes: 5 additions & 0 deletions app/screens/Receive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export const RECEIVE_SCREEN = 'RECEIVE_SCREEN'
* @extends React.PureComponent<Props, {}, never>
*/
class ReceiveScreen extends React.PureComponent {
/** @type {import('react-navigation-stack').NavigationStackOptions} */
static navigationOptions = {
headerShown: false,
}

state = {
step: 1,
maxStep: 2,
Expand Down
5 changes: 5 additions & 0 deletions app/screens/Send/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ export const SEND_SCREEN = 'SEND_SCREEN'
* @extends React.PureComponent<Props, State, never>
*/
class SendScreen extends React.PureComponent {
/** @type {import('react-navigation-stack').NavigationStackOptions} */
static navigationOptions = {
headerShown: false,
}

/**@type State */
state = {
description: '',
Expand Down
1 change: 1 addition & 0 deletions app/screens/WalletSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class WalletSettings extends React.PureComponent {
*/
static navigationOptions = {
header: () => null,
headerShown: false,
// drawerIcon: () => {
// return (<IconDrawerWalletSettings />)
// },
Expand Down
9 changes: 0 additions & 9 deletions app/services/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,6 @@ export const getStoredAuthData = async () => {
return null
}

getStore().dispatch(Actions.hostWasSet(currNodeURL))
getStore().dispatch(
Actions.authed({
alias: sad.authData.alias,
gunPublicKey: sad.authData.publicKey,
token: sad.authData.token,
}),
)

return {
...sad,
authData: {
Expand Down
104 changes: 55 additions & 49 deletions app/store/actions/ChatActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,58 +51,64 @@ export const ACTIONS = {
/**
* Fetches the Node's info
* @param {((chats: Common.Schema.Chat[]) => void)=} callback
* @returns {import('redux-thunk').ThunkAction<Promise<Common.Schema.Chat[]>, {}, {}, import('redux').AnyAction>}
* @returns {(d: (a: any) => any) => Promise<any>}
*/
export const subscribeOnChats = callback => dispatch =>
new Promise((resolve, reject) => {
// TODO: Move to saga
API.Events.onChats(chats => {
try {
const contacts = chats.map(chat => ({
pk: chat.recipientPublicKey,
avatar: chat.recipientAvatar,
displayName: chat.recipientDisplayName,
}))

const messages = chats.reduce(
(messages, chat) => ({
...messages,
[chat.recipientPublicKey]: chat.messages,
}),
{},
)

dispatch({
type: ACTIONS.LOAD_CONTACTS,
data: contacts,
})

dispatch({
type: ACTIONS.LOAD_MESSAGES,
data: messages,
})

/** @type {ReceivedChatsAction} */
const receivedChatsAction = {
type: 'chats/receivedChats',
data: {
chats,
},
export const subscribeOnChats = callback => async dispatch => {
try {
await Common.Utils.makePromise((resolve, reject) => {
API.Events.onChats(chats => {
try {
const contacts = chats.map(chat => ({
pk: chat.recipientPublicKey,
avatar: chat.recipientAvatar,
displayName: chat.recipientDisplayName,
}))

const messages = chats.reduce(
(messages, chat) => ({
...messages,
[chat.recipientPublicKey]: chat.messages,
}),
{},
)

dispatch({
type: ACTIONS.LOAD_CONTACTS,
data: contacts,
})

dispatch({
type: ACTIONS.LOAD_MESSAGES,
data: messages,
})

/** @type {ReceivedChatsAction} */
const receivedChatsAction = {
type: 'chats/receivedChats',
data: {
chats,
},
}

dispatch(receivedChatsAction)

if (callback) {
callback(chats)
}

resolve(chats)
} catch (err) {
Logger.log(
`Error inside callback to onChats in subscribeOnChats thunk: ${err.message}`,
)
reject(err)
}

dispatch(receivedChatsAction)

if (callback) {
callback(chats)
}

resolve(chats)
} catch (err) {
Logger.log(err)
reject(err)
}
})
})
})
} catch (e) {
Logger.log(`Error inside subscribeOnChats thunk: ${e.message}`)
}
}

/**
* Selects a contact (useful for easily referencing the currently focused contact)
Expand Down
Loading

0 comments on commit e39a523

Please sign in to comment.