mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-12 18:51:21 +01:00
FIX: Send transaction crash #6751
This commit is contained in:
parent
a0fe77a98c
commit
63633336b8
2 changed files with 35 additions and 20 deletions
|
@ -1,6 +1,13 @@
|
||||||
import React, { Ref, useCallback, useMemo } from 'react';
|
import React, { Ref, useCallback, useMemo } from 'react';
|
||||||
import { Platform, Pressable, TouchableOpacity, View } from 'react-native';
|
import { Platform, Pressable, TouchableOpacity, View } from 'react-native';
|
||||||
import { ContextMenuView, RenderItem, OnPressMenuItemEventObject, MenuState, IconConfig } from 'react-native-ios-context-menu';
|
import {
|
||||||
|
ContextMenuView,
|
||||||
|
RenderItem,
|
||||||
|
OnPressMenuItemEventObject,
|
||||||
|
MenuState,
|
||||||
|
IconConfig,
|
||||||
|
MenuElementConfig,
|
||||||
|
} from 'react-native-ios-context-menu';
|
||||||
import { MenuView, MenuAction, NativeActionEvent } from '@react-native-menu/menu';
|
import { MenuView, MenuAction, NativeActionEvent } from '@react-native-menu/menu';
|
||||||
import { ToolTipMenuProps, Action } from './types';
|
import { ToolTipMenuProps, Action } from './types';
|
||||||
|
|
||||||
|
@ -21,6 +28,7 @@ const ToolTipMenu = React.memo((props: ToolTipMenuProps, ref?: Ref<any>) => {
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const mapMenuItemForContextMenuView = useCallback((action: Action) => {
|
const mapMenuItemForContextMenuView = useCallback((action: Action) => {
|
||||||
|
if (!action.id) return null;
|
||||||
return {
|
return {
|
||||||
actionKey: action.id.toString(),
|
actionKey: action.id.toString(),
|
||||||
actionTitle: action.text,
|
actionTitle: action.text,
|
||||||
|
@ -30,7 +38,8 @@ const ToolTipMenu = React.memo((props: ToolTipMenuProps, ref?: Ref<any>) => {
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const mapMenuItemForMenuView = useCallback((action: Action): MenuAction => {
|
const mapMenuItemForMenuView = useCallback((action: Action): MenuAction | null => {
|
||||||
|
if (!action.id) return null;
|
||||||
return {
|
return {
|
||||||
id: action.id.toString(),
|
id: action.id.toString(),
|
||||||
title: action.text,
|
title: action.text,
|
||||||
|
@ -41,28 +50,34 @@ const ToolTipMenu = React.memo((props: ToolTipMenuProps, ref?: Ref<any>) => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const contextMenuItems = useMemo(() => {
|
const contextMenuItems = useMemo(() => {
|
||||||
const flattenedActions = props.actions.flat();
|
const flattenedActions = props.actions.flat().filter(action => action.id);
|
||||||
return flattenedActions.map(mapMenuItemForContextMenuView);
|
return flattenedActions.map(mapMenuItemForContextMenuView).filter(item => item !== null) as MenuElementConfig[];
|
||||||
}, [props.actions, mapMenuItemForContextMenuView]);
|
}, [props.actions, mapMenuItemForContextMenuView]);
|
||||||
|
|
||||||
const menuViewItemsIOS = useMemo(() => {
|
const menuViewItemsIOS = useMemo(() => {
|
||||||
return props.actions.map(actionGroup => {
|
return props.actions
|
||||||
if (Array.isArray(actionGroup)) {
|
.map(actionGroup => {
|
||||||
return {
|
if (Array.isArray(actionGroup) && actionGroup.length > 0) {
|
||||||
id: actionGroup[0].id.toString(),
|
return {
|
||||||
title: '',
|
id: actionGroup[0].id.toString(),
|
||||||
subactions: actionGroup.map(mapMenuItemForMenuView),
|
title: '',
|
||||||
displayInline: true,
|
subactions: actionGroup
|
||||||
};
|
.filter(action => action.id)
|
||||||
} else {
|
.map(mapMenuItemForMenuView)
|
||||||
return mapMenuItemForMenuView(actionGroup);
|
.filter(item => item !== null) as MenuAction[],
|
||||||
}
|
displayInline: true,
|
||||||
});
|
};
|
||||||
|
} else if (!Array.isArray(actionGroup) && actionGroup.id) {
|
||||||
|
return mapMenuItemForMenuView(actionGroup);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
.filter(item => item !== null) as MenuAction[];
|
||||||
}, [props.actions, mapMenuItemForMenuView]);
|
}, [props.actions, mapMenuItemForMenuView]);
|
||||||
|
|
||||||
const menuViewItemsAndroid = useMemo(() => {
|
const menuViewItemsAndroid = useMemo(() => {
|
||||||
const mergedActions = props.actions.flat();
|
const mergedActions = props.actions.flat().filter(action => action.id);
|
||||||
return mergedActions.map(mapMenuItemForMenuView);
|
return mergedActions.map(mapMenuItemForMenuView).filter(item => item !== null) as MenuAction[];
|
||||||
}, [props.actions, mapMenuItemForMenuView]);
|
}, [props.actions, mapMenuItemForMenuView]);
|
||||||
|
|
||||||
const handlePressMenuItemForContextMenuView = useCallback(
|
const handlePressMenuItemForContextMenuView = useCallback(
|
||||||
|
@ -138,7 +153,7 @@ const ToolTipMenu = React.memo((props: ToolTipMenuProps, ref?: Ref<any>) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Platform.OS === 'ios' && renderPreview ? renderContextMenuView() : renderMenuView();
|
return props.actions.length > 0 ? (Platform.OS === 'ios' && renderPreview ? renderContextMenuView() : renderMenuView()) : null;
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ToolTipMenu;
|
export default ToolTipMenu;
|
||||||
|
|
|
@ -17,7 +17,7 @@ const WatchOnlyWarning: React.FC<Props> = ({ handleDismiss, isLoading }) => {
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<Icon name="warning" color="#FFFF" />
|
<Icon name="warning" color="#FFFF" />
|
||||||
<Text style={styles.title}>{loc.transactions.watchOnlyWarningTitle}</Text>
|
<Text style={styles.title}>{loc.transactions.watchOnlyWarningTitle}</Text>
|
||||||
<Text style={styles.description}>{loc.transactions.watchOnlyWarningDescription}</Text>
|
<Text style={styles.description}>{loc.transactions.watchOnlyWarningDescription}</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue