yarn lint fix
This commit is contained in:
@@ -6,7 +6,10 @@ import { UseFormRegister, UseFormSetValue, FieldValues, Path, FieldErrors } from
|
||||
import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager';
|
||||
import { PasteFromClipboard } from './ClipboardActions';
|
||||
|
||||
export const useCopyAllSupport = (inputRef: React.MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null>, onPasteValue?: (value: string) => void) => {
|
||||
export const useCopyAllSupport = (
|
||||
inputRef: React.MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null>,
|
||||
onPasteValue?: (value: string) => void,
|
||||
) => {
|
||||
useEffect(() => {
|
||||
if (!inputRef.current) return undefined;
|
||||
|
||||
@@ -457,4 +460,4 @@ export const HookFormCurrencyFieldWithPaste = <TFieldValues extends FieldValues>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -43,48 +43,48 @@ export const CurrencyFormFieldWithPaste = ({
|
||||
};
|
||||
|
||||
onChanged(decCoin);
|
||||
|
||||
|
||||
if (inputRef.current) {
|
||||
inputRef.current.value = cleanedValue;
|
||||
|
||||
|
||||
const inputEvent = new Event('input', { bubbles: true });
|
||||
inputRef.current.dispatchEvent(inputEvent);
|
||||
|
||||
|
||||
const changeEvent = new Event('change', { bubbles: true });
|
||||
inputRef.current.dispatchEvent(changeEvent);
|
||||
|
||||
|
||||
inputRef.current.focus();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const pasteEventHandler = (e: ClipboardEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
const { clipboardData } = e;
|
||||
if (!clipboardData) return;
|
||||
|
||||
const pastedText = clipboardData.getData('text');
|
||||
if (!pastedText) return;
|
||||
|
||||
processPastedText(pastedText);
|
||||
};
|
||||
|
||||
const findInputElement = () => {
|
||||
if (fieldRef.current) {
|
||||
const input = fieldRef.current.querySelector('input');
|
||||
if (input) {
|
||||
inputRef.current = input;
|
||||
|
||||
|
||||
// Set up paste event handler
|
||||
input.addEventListener('paste', pasteEventHandler as EventListener);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const pasteEventHandler = (e: ClipboardEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
const clipboardData = e.clipboardData;
|
||||
if (!clipboardData) return;
|
||||
|
||||
const pastedText = clipboardData.getData('text');
|
||||
if (!pastedText) return;
|
||||
|
||||
processPastedText(pastedText);
|
||||
};
|
||||
|
||||
findInputElement();
|
||||
const timeoutId = setTimeout(findInputElement, 200);
|
||||
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeoutId);
|
||||
if (inputRef.current) {
|
||||
@@ -98,7 +98,7 @@ export const CurrencyFormFieldWithPaste = ({
|
||||
if (inputRef.current && document.activeElement === inputRef.current) {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === 'v') {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
try {
|
||||
const clipboardText = await navigator.clipboard.readText();
|
||||
if (clipboardText) {
|
||||
@@ -112,7 +112,7 @@ export const CurrencyFormFieldWithPaste = ({
|
||||
};
|
||||
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
@@ -143,4 +143,4 @@ export const CurrencyFormFieldWithPaste = ({
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -47,8 +47,7 @@ const shouldBeFiltered = (item: any): boolean => {
|
||||
// For pending delegations, keep "Delegate" events but filter out "Undelegate" events with empty node_identity
|
||||
if (isPendingDelegation(item)) {
|
||||
// If it's an undelegate event with empty node_identity, filter it out
|
||||
if ((!item.node_identity || item.node_identity === '') &&
|
||||
item.event && item.event.kind === 'Undelegate') {
|
||||
if ((!item.node_identity || item.node_identity === '') && item.event && item.event.kind === 'Undelegate') {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -112,7 +111,7 @@ const EnhancedTableHead: FCWithChildren<EnhancedTableProps> = ({ order, orderBy,
|
||||
minWidth: headCell.id === 'node_identity' ? '120px' : '80px',
|
||||
whiteSpace: 'nowrap',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis'
|
||||
textOverflow: 'ellipsis',
|
||||
}}
|
||||
>
|
||||
<TableSortLabel
|
||||
@@ -138,10 +137,12 @@ const EnhancedTableHead: FCWithChildren<EnhancedTableProps> = ({ order, orderBy,
|
||||
maxWidth: '120px',
|
||||
whiteSpace: 'nowrap',
|
||||
overflow: 'hidden',
|
||||
textAlign: 'center'
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<Typography noWrap align="center">Actions</Typography>
|
||||
<Typography noWrap align="center">
|
||||
Actions
|
||||
</Typography>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
@@ -182,7 +183,7 @@ export const DelegationList: FCWithChildren<{
|
||||
// Filter out empty placeholder rows
|
||||
const filteredItems = React.useMemo(() => {
|
||||
if (!sorted) return [];
|
||||
return sorted.filter(item => !shouldBeFiltered(item));
|
||||
return sorted.filter((item) => !shouldBeFiltered(item));
|
||||
}, [sorted]);
|
||||
|
||||
// Check if any delegations have pruning errors
|
||||
@@ -223,14 +224,16 @@ export const DelegationList: FCWithChildren<{
|
||||
)}
|
||||
|
||||
{/* Add horizontal scrolling to the table container */}
|
||||
<TableContainer sx={{
|
||||
width: '100%',
|
||||
overflowX: 'auto',
|
||||
'& .MuiTable-root': {
|
||||
tableLayout: 'fixed',
|
||||
minWidth: 650
|
||||
}
|
||||
}}>
|
||||
<TableContainer
|
||||
sx={{
|
||||
width: '100%',
|
||||
overflowX: 'auto',
|
||||
'& .MuiTable-root': {
|
||||
tableLayout: 'fixed',
|
||||
minWidth: 650,
|
||||
},
|
||||
}}
|
||||
>
|
||||
{isLoading && <LoadingModal text="Please wait. Refreshing..." />}
|
||||
<ErrorModal
|
||||
open={Boolean(delegationItemErrors)}
|
||||
@@ -245,45 +248,53 @@ export const DelegationList: FCWithChildren<{
|
||||
<TableBody>
|
||||
{filteredItems?.length
|
||||
? filteredItems.map((item: any, _index: number) => {
|
||||
if (isPendingDelegation(item)) {
|
||||
const pendingKey = `pending-${item.event.mix_id}-${item.event.address}-${Date.now()}-${Math.random()}`;
|
||||
if (isPendingDelegation(item)) {
|
||||
const pendingKey = `pending-${item.event.mix_id}-${
|
||||
item.event.address
|
||||
}-${Date.now()}-${Math.random()}`;
|
||||
|
||||
if (item.event && item.event.kind === 'Delegate' && (!item.node_identity || item.node_identity === '')) {
|
||||
return <PendingDelegationItem
|
||||
key={pendingKey}
|
||||
item={{
|
||||
...item,
|
||||
node_identity: `Mix Identity Key ${item.event.mix_id}`
|
||||
}}
|
||||
explorerUrl={explorerUrl}
|
||||
/>;
|
||||
if (
|
||||
item.event &&
|
||||
item.event.kind === 'Delegate' &&
|
||||
(!item.node_identity || item.node_identity === '')
|
||||
) {
|
||||
return (
|
||||
<PendingDelegationItem
|
||||
key={pendingKey}
|
||||
item={{
|
||||
...item,
|
||||
node_identity: `Mix Identity Key ${item.event.mix_id}`,
|
||||
}}
|
||||
explorerUrl={explorerUrl}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <PendingDelegationItem key={pendingKey} item={item} explorerUrl={explorerUrl} />;
|
||||
}
|
||||
|
||||
return <PendingDelegationItem key={pendingKey} item={item} explorerUrl={explorerUrl} />;
|
||||
}
|
||||
if (isDelegation(item)) {
|
||||
if (!item.node_identity || item.node_identity === '-' || item.node_identity === '...') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isDelegation(item)) {
|
||||
if (!item.node_identity || item.node_identity === '-' || item.node_identity === '...') {
|
||||
return null;
|
||||
return (
|
||||
<DelegationItem
|
||||
key={`delegation-${item.mix_id}`}
|
||||
item={item}
|
||||
explorerUrl={explorerUrl}
|
||||
nodeIsUnbonded={Boolean(!item.node_identity)}
|
||||
onItemActionClick={onItemActionClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<DelegationItem
|
||||
key={`delegation-${item.mix_id}`}
|
||||
item={item}
|
||||
explorerUrl={explorerUrl}
|
||||
nodeIsUnbonded={Boolean(!item.node_identity)}
|
||||
onItemActionClick={onItemActionClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
return null;
|
||||
})
|
||||
: null}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -20,9 +20,7 @@ export const PendingDelegationItem = ({ item, explorerUrl }: { item: WrappedDele
|
||||
<TableCell>-</TableCell>
|
||||
<TableCell>-</TableCell>
|
||||
<TableCell>
|
||||
<Box sx={{ textAlign: 'left' }}>
|
||||
{item.event.amount?.amount} NYM
|
||||
</Box>
|
||||
<Box sx={{ textAlign: 'left' }}>{item.event.amount?.amount} NYM</Box>
|
||||
</TableCell>
|
||||
<TableCell>-</TableCell>
|
||||
<TableCell sx={{ textAlign: 'center' }}>
|
||||
@@ -30,18 +28,17 @@ export const PendingDelegationItem = ({ item, explorerUrl }: { item: WrappedDele
|
||||
<Tooltip
|
||||
title={
|
||||
<div style={{ textAlign: 'center', width: '100%' }}>
|
||||
Your delegation of {item.event.amount?.amount} {item.event.amount?.denom} will take effect
|
||||
when the new epoch starts. There is a new
|
||||
epoch every hour.
|
||||
Your delegation of {item.event.amount?.amount} {item.event.amount?.denom} will take effect when the new
|
||||
epoch starts. There is a new epoch every hour.
|
||||
</div>
|
||||
}
|
||||
arrow
|
||||
PopperProps={{
|
||||
sx: {
|
||||
'& .MuiTooltip-tooltip': {
|
||||
textAlign: 'center'
|
||||
}
|
||||
}
|
||||
textAlign: 'center',
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Chip label="Pending Events" />
|
||||
@@ -49,4 +46,4 @@ export const PendingDelegationItem = ({ item, explorerUrl }: { item: WrappedDele
|
||||
</Box>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
);
|
||||
|
||||
@@ -69,7 +69,7 @@ export const SendInputModal = ({
|
||||
const [addressIsValid, setAddressIsValid] = useState(false);
|
||||
const [errorAmount, setErrorAmount] = useState<string | undefined>();
|
||||
const [errorFee, setErrorFee] = useState<string | undefined>();
|
||||
|
||||
|
||||
// Calculate noAccount at the component root level instead of using useEffect
|
||||
const noAccount = !balance || balance === '0' || parseFloat(balance) === 0;
|
||||
|
||||
@@ -295,4 +295,4 @@ export const SendInputModal = ({
|
||||
)}
|
||||
</SimpleModal>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -18,4 +18,4 @@ export const TauriLink: React.FC<LinkProps & any> = (props) => {
|
||||
};
|
||||
|
||||
return <Link href={href} onClick={handleClick} {...restProps} />;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -402,10 +402,10 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => {
|
||||
return (
|
||||
<>
|
||||
{/* Main container - make sure it constrains width properly */}
|
||||
<Paper
|
||||
elevation={0}
|
||||
sx={{
|
||||
p: 3,
|
||||
<Paper
|
||||
elevation={0}
|
||||
sx={{
|
||||
p: 3,
|
||||
mt: 4,
|
||||
maxWidth: '100%',
|
||||
overflowX: 'hidden',
|
||||
@@ -455,11 +455,9 @@ export const Delegation: FC<{ isStorybook?: boolean }> = ({ isStorybook }) => {
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
|
||||
{/* Add a container to ensure delegations are constrained */}
|
||||
<Box sx={{ width: '100%', overflowX: 'hidden' }}>
|
||||
{delegationsComponent(delegations)}
|
||||
</Box>
|
||||
<Box sx={{ width: '100%', overflowX: 'hidden' }}>{delegationsComponent(delegations)}</Box>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
@@ -556,4 +554,4 @@ export const DelegationPage: FC<{ isStorybook?: boolean }> = ({ isStorybook }) =
|
||||
<Delegation isStorybook={isStorybook} />
|
||||
</RewardsContextProvider>
|
||||
</DelegationContextProvider>
|
||||
);
|
||||
);
|
||||
|
||||
@@ -10,15 +10,18 @@ let interFontLink: HTMLLinkElement | null = null;
|
||||
const FontLoader = () => {
|
||||
useEffect(() => {
|
||||
// Skip if already initialized
|
||||
if (fontsInitialized === true) { return; }
|
||||
|
||||
if (fontsInitialized === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
fontsInitialized = true;
|
||||
|
||||
|
||||
interFontLink = document.createElement('link');
|
||||
interFontLink.rel = 'stylesheet';
|
||||
interFontLink.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap';
|
||||
document.head.appendChild(interFontLink);
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
return () => {
|
||||
// Only clean up if the component is truly being unmounted
|
||||
if (interFontLink && document.head.contains(interFontLink)) {
|
||||
@@ -46,4 +49,4 @@ export const NymWalletThemeWithMode: FCWithChildren<{ mode: PaletteMode; childre
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user