mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 23:08:07 +01:00
Merge pull request #6752 from BlueWallet/Send-transaction-crash-#6751
FIX: Send transaction crash #6751
This commit is contained in:
commit
5a25cb2b4b
2 changed files with 35 additions and 20 deletions
|
@ -1,6 +1,13 @@
|
|||
import React, { Ref, useCallback, useMemo } from 'react';
|
||||
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 { ToolTipMenuProps, Action } from './types';
|
||||
|
||||
|
@ -21,6 +28,7 @@ const ToolTipMenu = React.memo((props: ToolTipMenuProps, ref?: Ref<any>) => {
|
|||
} = props;
|
||||
|
||||
const mapMenuItemForContextMenuView = useCallback((action: Action) => {
|
||||
if (!action.id) return null;
|
||||
return {
|
||||
actionKey: action.id.toString(),
|
||||
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 {
|
||||
id: action.id.toString(),
|
||||
title: action.text,
|
||||
|
@ -41,28 +50,34 @@ const ToolTipMenu = React.memo((props: ToolTipMenuProps, ref?: Ref<any>) => {
|
|||
}, []);
|
||||
|
||||
const contextMenuItems = useMemo(() => {
|
||||
const flattenedActions = props.actions.flat();
|
||||
return flattenedActions.map(mapMenuItemForContextMenuView);
|
||||
const flattenedActions = props.actions.flat().filter(action => action.id);
|
||||
return flattenedActions.map(mapMenuItemForContextMenuView).filter(item => item !== null) as MenuElementConfig[];
|
||||
}, [props.actions, mapMenuItemForContextMenuView]);
|
||||
|
||||
const menuViewItemsIOS = useMemo(() => {
|
||||
return props.actions.map(actionGroup => {
|
||||
if (Array.isArray(actionGroup)) {
|
||||
return {
|
||||
id: actionGroup[0].id.toString(),
|
||||
title: '',
|
||||
subactions: actionGroup.map(mapMenuItemForMenuView),
|
||||
displayInline: true,
|
||||
};
|
||||
} else {
|
||||
return mapMenuItemForMenuView(actionGroup);
|
||||
}
|
||||
});
|
||||
return props.actions
|
||||
.map(actionGroup => {
|
||||
if (Array.isArray(actionGroup) && actionGroup.length > 0) {
|
||||
return {
|
||||
id: actionGroup[0].id.toString(),
|
||||
title: '',
|
||||
subactions: actionGroup
|
||||
.filter(action => action.id)
|
||||
.map(mapMenuItemForMenuView)
|
||||
.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]);
|
||||
|
||||
const menuViewItemsAndroid = useMemo(() => {
|
||||
const mergedActions = props.actions.flat();
|
||||
return mergedActions.map(mapMenuItemForMenuView);
|
||||
const mergedActions = props.actions.flat().filter(action => action.id);
|
||||
return mergedActions.map(mapMenuItemForMenuView).filter(item => item !== null) as MenuAction[];
|
||||
}, [props.actions, mapMenuItemForMenuView]);
|
||||
|
||||
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;
|
||||
|
|
|
@ -17,7 +17,7 @@ const WatchOnlyWarning: React.FC<Props> = ({ handleDismiss, isLoading }) => {
|
|||
</TouchableOpacity>
|
||||
<Icon name="warning" color="#FFFF" />
|
||||
<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>
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue