mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-20 23:21:36 +03:00
app_store UI: fix false missing local downloads message on publish
This commit is contained in:
parent
1c0e9ff597
commit
cdd04f12f9
@ -12,7 +12,7 @@ const NAME_INVALID = "Package name must contain only valid characters (a-z, 0-9,
|
||||
|
||||
export default function PublishPage() {
|
||||
const { openConnectModal } = useConnectModal();
|
||||
const { ourApps, fetchOurApps, downloads } = useAppsStore();
|
||||
const { ourApps, fetchOurApps, downloads, fetchDownloadsForApp } = useAppsStore();
|
||||
const publicClient = usePublicClient();
|
||||
|
||||
const { address, isConnected, isConnecting } = useAccount();
|
||||
@ -34,6 +34,13 @@ export default function PublishPage() {
|
||||
fetchOurApps();
|
||||
}, [fetchOurApps]);
|
||||
|
||||
useEffect(() => {
|
||||
if (packageName && publisherId) {
|
||||
const id = `${packageName}:${publisherId}`;
|
||||
fetchDownloadsForApp(id);
|
||||
}
|
||||
}, [packageName, publisherId, fetchDownloadsForApp]);
|
||||
|
||||
const validatePackageName = useCallback((name: string) => {
|
||||
// Allow lowercase letters, numbers, hyphens, and dots
|
||||
const validNameRegex = /^[a-z0-9.-]+$/;
|
||||
@ -69,9 +76,12 @@ export default function PublishPage() {
|
||||
// Check if code_hashes exist in metadata and is an object
|
||||
if (metadata.properties && metadata.properties.code_hashes && typeof metadata.properties.code_hashes === 'object') {
|
||||
const codeHashes = metadata.properties.code_hashes;
|
||||
const missingHashes = Object.entries(codeHashes).filter(([version, hash]) =>
|
||||
!downloads[`${packageName}:${publisherId}`]?.some(d => d.File?.name === `${hash}.zip`)
|
||||
);
|
||||
console.log('Available downloads:', downloads[`${packageName}:${publisherId}`]);
|
||||
|
||||
const missingHashes = Object.entries(codeHashes).filter(([version, hash]) => {
|
||||
const hasDownload = downloads[`${packageName}:${publisherId}`]?.some(d => d.File?.name === `${hash}.zip`);
|
||||
return !hasDownload;
|
||||
});
|
||||
|
||||
if (missingHashes.length > 0) {
|
||||
setMetadataError(`Missing local downloads for mirroring versions: ${missingHashes.map(([version]) => version).join(', ')}`);
|
||||
|
Loading…
Reference in New Issue
Block a user