ln decoder, default mint, drawer formatting

This commit is contained in:
lemonknowsall committed 2025-10-19 11:05:35 -07:00
1 parent 7390dd6c19
commit 617edd1784
8 files changed
+422 -130

No files matched your search

+28 -3
View File
@@ -61,6 +61,20 @@ export function useMintManager({
normalizedUrl = `https://${normalizedUrl}`;
}
// Check if mint with same name already exists (case insensitive)
const existingMint = mints.find(mint =>
mint.url.toLowerCase() === normalizedUrl.toLowerCase()
);
if (existingMint) {
toast({
variant: 'destructive',
title: 'Mint Already Exists',
description: 'A mint with this URL already exists',
});
return;
}
await coco.mint.addMint(normalizedUrl);
setMintUrl('');
@@ -75,7 +89,7 @@ export function useMintManager({
description: err instanceof Error ? err.message : 'Unknown error',
});
}
}, [mintUrl, coco, toast]);
}, [mintUrl, coco, mints, toast]);
// Show remove confirmation modal
const handleRemoveMintClick = useCallback((mint: CashuMint) => {
@@ -190,14 +204,25 @@ export function useMintManager({
[repositories, toast]
);
// Auto-select first mint when mints change
// Auto-select first mint when mints change, or add default mint if none exist
useEffect(() => {
if (mints.length > 0 && !activeMintUrl) {
// Select first mint initially - user can change via dropdown
// Don't sync to npub.cash on auto-select, only on manual changes
handleSetActiveMint(mints[0].url, false);
} else if (mints.length === 0 && !activeMintUrl && coco) {
// Add default mint if no mints exist
const addDefaultMint = async () => {
try {
await coco.mint.addMint('https://mint.chorus.community');
// The mint will be added and refreshMints will be called via event listeners
} catch (err) {
console.error('Failed to add default mint:', err);
}
};
addDefaultMint();
}
}, [mints, activeMintUrl, handleSetActiveMint]);
}, [mints, activeMintUrl, handleSetActiveMint, coco]);
return {
activeMintUrl,